public IActionResult Edit(DangJibenInfoViewModel model) { var response = ResponseModelFactory.CreateInstance; Guid guid = (Guid)model.DangOrganizationUuid; if (ConfigurationManager.AppSettings.IsTrialVersion) { response.SetIsTrial(); return(Ok(response)); } using (_dbContext) { string name = model.DangOrganizationName; var query = _dbContext.DangOrganization.FirstOrDefault(x => x.DangOrganizationName == name); var entity = _dbContext.DangOrganization.FirstOrDefault(x => x.DangOrganizationUuid == guid); if (query != null && entity.DangOrganizationName != name) { response.SetFailed("该组织已存在"); return(Ok(response)); } entity.DangOrganizationName = model.DangOrganizationName; entity.DangType = model.DangType; entity.DangClerk = model.DangClerk; int res = _dbContext.SaveChanges(); if (res > 0) { ToLog.AddLog("编辑", "成功:编辑:党组织信息一条数据", _dbContext); } response.SetSuccess("修改成功"); return(Ok(response)); } }
public IActionResult Create(DangJibenInfoViewModel model) { var response = ResponseModelFactory.CreateInstance; using (_dbContext) { string name = model.DangOrganizationName; var query = _dbContext.DangOrganization.FirstOrDefault(x => x.DangOrganizationName == name); if (query != null) { response.SetFailed("该组织已存在"); return(Ok(response)); } var entity = new HaikanSmartTownCockpit.Api.Entities.DangOrganization(); entity.DangOrganizationUuid = Guid.NewGuid(); entity.DangOrganizationName = model.DangOrganizationName; entity.DangType = model.DangType; entity.DangClerk = model.DangClerk; entity.ChuangliTime = DateTime.Now.ToString("yyyy-MM-dd"); entity.AddTime = DateTime.Now.ToString("yyyy-MM-dd"); entity.IsDeleted = 0; _dbContext.DangOrganization.Add(entity); int res = _dbContext.SaveChanges(); if (res > 0) { ToLog.AddLog("添加", "成功:添加:党组织信息一条数据", _dbContext); } response.SetSuccess("添加成功"); return(Ok(response)); } }
public IActionResult DangJibenInfoCreate(DangJibenInfoViewModel model) { var response = ResponseModelFactory.CreateInstance; using (_dbContext) { var entity = new HaikanSmartTownCockpit.Api.Entities.CpcmanInfo(); entity.CpcmanUuid = Guid.NewGuid(); entity.RealName = model.RealName; entity.Sex = model.Sex; entity.Education = model.Education; entity.DangOrganizationName = model.DangOrganizationName; entity.Politics = model.Politics; if (model.Birth != null && model.Birth != "") { entity.Birth = DateTime.Parse(model.Birth); //DateTime now = DateTime.Now; //DateTime birth = Convert.ToDateTime(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.AddTime = DateTime.Now.ToString("yyyy-MM-dd"); //entity.AddPeople = model.addPeople; entity.IsDeleted = 0; _dbContext.CpcmanInfo.Add(entity); int res = _dbContext.SaveChanges(); if (res > 0) { ToLog.AddLog("添加", "成功:添加:党员信息一条数据", _dbContext); } response.SetSuccess("添加成功"); return(Ok(response)); } }
public IActionResult DangJibenInfoEdit(DangJibenInfoViewModel model) { var response = ResponseModelFactory.CreateInstance; string guid = model.CpcmanUuid; if (ConfigurationManager.AppSettings.IsTrialVersion) { response.SetIsTrial(); return(Ok(response)); } using (_dbContext) { var entity = _dbContext.CpcmanInfo.FirstOrDefault(x => x.CpcmanUuid == Guid.Parse(guid)); entity.RealName = model.RealName; entity.Sex = model.Sex; entity.Education = model.Education; entity.Politics = model.Politics; entity.DangOrganizationName = model.DangOrganizationName; if (model.Birth != null && model.Birth != "") { entity.Birth = DateTime.Parse(model.Birth); //DateTime now = DateTime.Now; //DateTime birth = Convert.ToDateTime(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; } int res = _dbContext.SaveChanges(); if (res > 0) { ToLog.AddLog("编辑", "成功:编辑:党员信息一条数据", _dbContext); } response.SetSuccess("修改成功"); return(Ok(response)); } }