public IActionResult GetEdit(MentallyViewModel model) { var response = ResponseModelFactory.CreateInstance; if (ConfigurationManager.AppSettings.IsTrialVersion) { response.SetIsTrial(); return(Ok(response)); } using (_dbContext) { var entity = _dbContext.Mentally.FirstOrDefault(x => x.MentallyUuid == model.MentallyUuid); entity.Name = model.Name; entity.Phone = model.Phone; entity.IdCard = model.IdCard; entity.Danger = model.Danger; entity.OwningGrid = model.OwningGrid; entity.Sex = model.Sex; entity.DateBirth = model.DateBirth; entity.ResidenceAddress = model.ResidenceAddress; entity.RegisteredAddress = model.RegisteredAddress; entity.PoliceStation = model.PoliceStation; entity.HousesNumber = model.HousesNumber; entity.CurrentAddress = model.CurrentAddress; entity.RoomReason = model.RoomReason; entity.OtherAddress = model.OtherAddress; entity.FormerName = model.FormerName; entity.Employer = model.Employer; entity.ContactPhone = model.ContactPhone; entity.Email = model.Email; entity.Nation = model.Nation; entity.PoliticalStatus = model.PoliticalStatus; entity.Education = model.Education; entity.Occupation = model.Occupation; entity.MaritalStatus = model.MaritalStatus; entity.BloodType = model.BloodType; entity.Religious = model.Religious; entity.Height = model.Height; entity.DiseaseName = model.DiseaseName; entity.Treatment = model.Treatment; entity.Rehabilitation = model.Rehabilitation; entity.Waiter = model.Waiter; entity.ServiceHours = model.ServiceHours; entity.Remarks = model.Remarks; int res = _dbContext.SaveChanges(); if (res > 0) { ToLog.AddLog("编辑", "成功:编辑:精神病人员信息一条数据", _dbContext); } response.SetSuccess("修改成功"); return(Ok(response)); } }
public IActionResult GetCreate(MentallyViewModel model) { var response = ResponseModelFactory.CreateInstance; using (_dbContext) { var entity = new HaikanSmartTownCockpit.Api.Entities.Mentally(); entity.MentallyUuid = Guid.NewGuid(); entity.Name = model.Name; entity.Phone = model.Phone; entity.Danger = model.Danger; entity.IdCard = model.IdCard; entity.OwningGrid = model.OwningGrid; entity.Sex = model.Sex; entity.DateBirth = model.DateBirth; entity.ResidenceAddress = model.ResidenceAddress; entity.RegisteredAddress = model.RegisteredAddress; entity.PoliceStation = model.PoliceStation; entity.HousesNumber = model.HousesNumber; entity.CurrentAddress = model.CurrentAddress; entity.RoomReason = model.RoomReason; entity.OtherAddress = model.OtherAddress; entity.FormerName = model.FormerName; entity.Employer = model.Employer; entity.ContactPhone = model.ContactPhone; entity.Email = model.Email; entity.Nation = model.Nation; entity.PoliticalStatus = model.PoliticalStatus; entity.Education = model.Education; entity.Occupation = model.Occupation; entity.MaritalStatus = model.MaritalStatus; entity.BloodType = model.BloodType; entity.Religious = model.Religious; entity.Height = model.Height; entity.DiseaseName = model.DiseaseName; entity.Treatment = model.Treatment; entity.Rehabilitation = model.Rehabilitation; entity.Waiter = model.Waiter; entity.ServiceHours = model.ServiceHours; entity.Remarks = model.Remarks; entity.IsDeleted = 0; _dbContext.Mentally.Add(entity); int res = _dbContext.SaveChanges(); if (res > 0) { ToLog.AddLog("添加", "成功:添加:精神病人员信息一条数据", _dbContext); } response.SetSuccess("添加成功"); return(Ok(response)); } }