New file |
| | |
| | | using AutoMapper; |
| | | using DTO; |
| | | using IServices; |
| | | using Microsoft.EntityFrameworkCore; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using zhengcaioa.Models; |
| | | |
| | | |
| | | namespace Services |
| | | { |
| | | public class LZhuanjiahuidumService : ILZhuanjiahuidumService |
| | | { |
| | | private readonly zhengcaioaContext _context; |
| | | private readonly IMapper _mapper; |
| | | public LZhuanjiahuidumService(zhengcaioaContext context, IMapper mapper) |
| | | { |
| | | _context = context; |
| | | _mapper = mapper; |
| | | } |
| | | |
| | | public ResultEntity save(LZhuanjiahuidumDTO dto) |
| | | { |
| | | ResultEntity resultEntity = new ResultEntity(); |
| | | try |
| | | { |
| | | var model = _mapper.Map<LZhuanjiahuidum>(dto); |
| | | if (String.IsNullOrEmpty(model.Id)) |
| | | { |
| | | model.Id = Guid.NewGuid().ToString(); |
| | | |
| | | |
| | | _context.LZhuanjiahuida.Add(model); |
| | | } |
| | | else |
| | | { |
| | | var updatepltRole = _context.LZhuanjiahuida.Find(model.Id); |
| | | updatepltRole.Userid = model.Userid; |
| | | updatepltRole.Username = model.Username; |
| | | updatepltRole.Anwser = model.Anwser; |
| | | updatepltRole.Question = model.Question; |
| | | updatepltRole.HuidaStatus = model.HuidaStatus; |
| | | |
| | | updatepltRole.RecStatus = model.RecStatus; |
| | | // updatepltRole.Creater = pltRole.Creater; |
| | | //updatepltRole.Createtime = pltRole.Createtime; |
| | | updatepltRole.Modifier = model.Modifier; |
| | | updatepltRole.Modifytime = model.Modifytime; |
| | | |
| | | } |
| | | |
| | | _context.SaveChanges(); |
| | | resultEntity.ReturnID = model.Id; |
| | | resultEntity.Result = true; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | resultEntity.Result = false; |
| | | resultEntity.Message = "保存失败,请联系管理员"; |
| | | |
| | | } |
| | | return resultEntity; |
| | | } |
| | | |
| | | public LZhuanjiahuidumDTO Get(string id) |
| | | { |
| | | var entity = _context.LZhuanjiahuida.Find(id); |
| | | |
| | | if (entity.RecStatus != "A") |
| | | { |
| | | entity = new LZhuanjiahuidum(); |
| | | } |
| | | var LZhuanjiahuidumDTO = _mapper.Map<LZhuanjiahuidumDTO>(entity); |
| | | return LZhuanjiahuidumDTO; |
| | | } |
| | | |
| | | public ResultDataEntity<LZhuanjiahuidumDTO> SearchByPaging(LZhuanjiahuidumDTOSearch searchEntity) |
| | | { |
| | | ResultDataEntity<LZhuanjiahuidumDTO> data = new ResultDataEntity<LZhuanjiahuidumDTO>(); |
| | | |
| | | |
| | | |
| | | var query = (from a in _context.LZhuanjiahuida//.Where(x => x.RecStatus == "A") |
| | | |
| | | |
| | | |
| | | where a.RecStatus == "A" |
| | | && (string.IsNullOrWhiteSpace(searchEntity.Username) || a.Username.Contains(searchEntity.Username.Trim())) |
| | | && (string.IsNullOrWhiteSpace(searchEntity.Question) || a.Question.Contains(searchEntity.Question.Trim())) |
| | | && (string.IsNullOrWhiteSpace(searchEntity.Userid) || a.Userid == searchEntity.Userid.Trim()) |
| | | && (string.IsNullOrWhiteSpace(searchEntity.HuidaStatus) || a.HuidaStatus == searchEntity.HuidaStatus.Trim()) |
| | | select new LZhuanjiahuidumDTO |
| | | { |
| | | Id = a.Id, |
| | | Userid = a.Userid, |
| | | Username = a.Username, |
| | | Anwser = a.Anwser, |
| | | Question = a.Question, |
| | | HuidaStatus = a.HuidaStatus, |
| | | |
| | | |
| | | |
| | | |
| | | RecStatus = a.RecStatus, |
| | | Creater = a.Creater, |
| | | Createtime = a.Createtime, |
| | | Modifier = a.Modifier, |
| | | Modifytime = a.Modifytime, |
| | | |
| | | }).OrderByDescending(x => x.Modifytime).ToList(); |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | //if (searchEntity.totalrows == 0) |
| | | searchEntity.totalrows = query.Count(); |
| | | var rolelist = query.Skip((searchEntity.page - 1) * searchEntity.rows).Take(searchEntity.rows).ToList(); |
| | | |
| | | data.LoadData(searchEntity, rolelist); |
| | | return data; |
| | | } |
| | | |
| | | public ResultEntity ModifyStatus(string id, string userid) |
| | | { |
| | | |
| | | ResultEntity result = new ResultEntity(); |
| | | result.Result = true; |
| | | |
| | | var model = _context.LZhuanjiahuida.Find(id); |
| | | if (model != null) |
| | | { |
| | | model.RecStatus = "D"; |
| | | model.Modifier = userid; |
| | | model.Modifytime = DateTime.Now; |
| | | _context.SaveChanges(); |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 获取所有有效角色 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public List<LZhuanjiahuidumDTO> GetList(string Userid = "", string question = "") |
| | | { |
| | | |
| | | |
| | | var listPosition = _context.LZhuanjiahuida.Where(r => r.RecStatus == "A").ToList(); |
| | | if (!string.IsNullOrEmpty(Userid)) |
| | | { |
| | | listPosition = listPosition.Where(x=>x.Userid== Userid).ToList(); |
| | | } |
| | | if (!string.IsNullOrEmpty(question)) |
| | | { |
| | | listPosition = listPosition.Where(x => x.Question == question).ToList(); |
| | | } |
| | | |
| | | var list = _mapper.Map<List<LZhuanjiahuidumDTO>>(listPosition); |
| | | return list; |
| | | } |
| | | } |
| | | } |