public IActionResult Create(dynamic model) { var response = ResponseModelFactory.CreateInstance; using (_dbContext) { var entity = new Userinfoty(); entity.UserInfoUuid = Guid.NewGuid(); entity.RealName = model.realName; entity.Sex = model.sex; entity.Birth = model.birth; entity.IdentityCard = model.identityCard; entity.Domicile = model.domicile; entity.Phone = model.phone; entity.Nation = model.nation; entity.Education = model.education; entity.JoinArmy = model.joinArmy; entity.Defense = "适龄青年"; entity.AddTime = DateTime.Now.ToString("yyyy-MM-dd"); entity.AddPeople = AuthContextService.CurrentUser.DisplayName; entity.IsDeleted = 0; _dbContext.Userinfoty.Add(entity); int res = _dbContext.SaveChanges(); if (res > 0) { ToLog.AddLog("添加", "成功:添加:统一人员信息一条数据", _dbContext); } response.SetSuccess("添加成功"); return(Ok(response)); } }
public IActionResult Create(dynamic model) { var response = ResponseModelFactory.CreateInstance; using (_dbContext) { var entity = new Userinfoty(); entity.UserInfoUuid = Guid.NewGuid(); entity.RealName = model.realName; entity.Sex = model.sex; entity.Birth = model.birth; entity.Education = model.education; entity.Category = model.category; entity.Partybranch = model.partybranch; entity.JoinDate = model.joinDate; entity.Phone = model.phone; entity.Residence = model.residence; entity.Work = model.work; entity.Evaluate = model.evaluate; entity.DyStaues = "1"; DateTime now = DateTime.Now; DateTime birth = model.birth; int age = now.Year - birth.Year; if (now.Month < birth.Month || (now.Month == birth.Month && now.Day < birth.Day)) { age--; } entity.Age = age < 0 ? 0 : age; entity.AddTime = DateTime.Now.ToString("yyyy-MM-dd"); entity.AddPeople = AuthContextService.CurrentUser.DisplayName; entity.IsDeleted = 0; _dbContext.Userinfoty.Add(entity); int res = _dbContext.SaveChanges(); if (res > 0) { ToLog.AddLog("添加", "成功:添加:统一人员信息一条数据", _dbContext); } response.SetSuccess("添加成功"); return(Ok(response)); } }