Ejemplo n.º 1
0
        public IActionResult Create(RectifyInfoViewModel model)
        {
            var response = ResponseModelFactory.CreateInstance;

            using (_dbContext)
            {
                //if (_dbContext.RectifyInfo.Count(x => x.MemberName == model.MemberName) > 0)
                //{
                //    response.SetFailed("名称已存在");
                //    return Ok(response);
                //}

                var entity = _mapper.Map <RectifyInfoViewModel, RectifyInfo>(model);
                entity.RectifyInfoUuid = Guid.NewGuid();
                entity.IsDeleted       = 0;

                entity.AddTime   = DateTime.Now.ToString("yyyy-MM-dd");
                entity.AddPeople = AuthContextService.CurrentUser.DisplayName;

                _dbContext.RectifyInfo.Add(entity);
                int res = _dbContext.SaveChanges();
                if (res > 0)
                {
                    ToLog.AddLog("添加", "成功:添加:矫正人员信息一条数据", _dbContext);
                }
                response.SetSuccess();
                return(Ok(response));
            }
        }
Ejemplo n.º 2
0
        public IActionResult Edit(RectifyInfoViewModel model)
        {
            var response = ResponseModelFactory.CreateInstance;

            using (_dbContext)
            {
                var entity = _dbContext.RectifyInfo.FirstOrDefault(x => x.RectifyInfoUuid == model.RectifyInfoUuid);
                if (entity == null)
                {
                    response.SetFailed("不存在");
                    return(Ok(response));
                }
                //if (_dbContext.RectifyInfo.Count(x => x.TeamName == model.TeamName && x.RectifyInfoUuid != model.RectifyInfoUuid) > 0)
                //{
                //    response.SetFailed("名称已存在");
                //    return Ok(response);
                //}
                entity.RectifyInfoUnit   = model.RectifyInfoUnit;
                entity.RectifyInfoName   = model.RectifyInfoName;
                entity.RectifyInfoStaues = model.RectifyInfoStaues;
                entity.DweiPhone         = model.DweiPhone;
                entity.ShangbanStaues    = model.ShangbanStaues;
                entity.RectifyType       = model.RectifyType;
                entity.RectifyTiem       = model.RectifyTiem;
                entity.KaishiTime        = model.KaishiTime;
                entity.JiesuTime         = model.JiesuTime;
                entity.Sex           = model.Sex;
                entity.Birthday      = model.Birthday;
                entity.IdentityCard  = model.IdentityCard;
                entity.Cirterion     = model.Cirterion;
                entity.Address       = model.Address;
                entity.Nation        = model.Nation;
                entity.Standard      = model.Standard;
                entity.Service       = model.Service;
                entity.ServicingTime = model.ServicingTime;
                entity.Marriage      = model.Marriage;
                int res = _dbContext.SaveChanges();
                if (res > 0)
                {
                    ToLog.AddLog("编辑", "成功:编辑:矫正人员信息一条数据", _dbContext);
                }
                response = ResponseModelFactory.CreateInstance;
                return(Ok(response));
            }
        }