public IActionResult GetEdit(ListOfKeyPetViewModel model) { var response = ResponseModelFactory.CreateInstance; if (ConfigurationManager.AppSettings.IsTrialVersion) { response.SetIsTrial(); return(Ok(response)); } using (_dbContext) { var entity = _dbContext.ListOfKeyPetitioners.FirstOrDefault(x => x.ListOfKeyPetitionersUuid == model.ListOfKeyPetitionersUuid); entity.Name = model.Name; entity.IdCard = model.IdCard; entity.Attention = model.Attention; entity.OwnedNetwork = model.OwnedNetwork; entity.Sex = model.Sex; entity.DateOfBirth = DateTime.Parse(model.DateOfBirth).ToString("yyyy-MM-dd"); entity.ResidenceAddress = model.ResidenceAddress; entity.RegisteredAddress = model.RegisteredAddress; entity.HouseholdRegistrationPoliceStation = model.HouseholdRegistrationPoliceStation; entity.NumberOfTheHouse = model.NumberOfTheHouse; entity.CurrentAddress = model.CurrentAddress; entity.NoRoomReason = model.NoRoomReason; entity.OtherAddress = model.OtherAddress; entity.FormerName = model.FormerName; entity.Employer = model.Employer; entity.ContactPhone = model.ContactPhone; entity.ContactNumber = model.ContactNumber; 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.ReligiousBelief = model.ReligiousBelief; entity.Height = model.Height; entity.PetitionStatus = model.PetitionStatus; entity.PetitionType = model.PetitionType; entity.ServiceMembers = model.ServiceMembers; entity.LatestServiceHours = model.LatestServiceHours; entity.Remarks = model.Remarks; int res = _dbContext.SaveChanges(); if (res > 0) { ToLog.AddLog("编辑", "成功:编辑:重点上访人员信息一条数据", _dbContext); } response.SetSuccess("修改成功"); return(Ok(response)); } }
public IActionResult GetCreate(ListOfKeyPetViewModel model) { var response = ResponseModelFactory.CreateInstance; using (_dbContext) { var entity = new HaikanSmartTownCockpit.Api.Entities.ListOfKeyPetitioners(); entity.ListOfKeyPetitionersUuid = Guid.NewGuid(); entity.Name = model.Name; entity.Attention = model.Attention; entity.IdCard = model.IdCard; entity.OwnedNetwork = model.OwnedNetwork; entity.ReasonForPetition = model.ReasonForPetition; entity.Sex = model.Sex; entity.DateOfBirth = DateTime.Parse(model.DateOfBirth).ToString("yyyy-MM-dd"); entity.ResidenceAddress = model.ResidenceAddress; entity.RegisteredAddress = model.RegisteredAddress; entity.HouseholdRegistrationPoliceStation = model.HouseholdRegistrationPoliceStation; entity.NumberOfTheHouse = model.NumberOfTheHouse; entity.CurrentAddress = model.CurrentAddress; entity.NoRoomReason = model.NoRoomReason; entity.OtherAddress = model.OtherAddress; entity.FormerName = model.FormerName; entity.Employer = model.Employer; entity.ContactPhone = model.ContactPhone; entity.ContactNumber = model.ContactNumber; 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.ReligiousBelief = model.ReligiousBelief; entity.Height = model.Height; entity.PetitionStatus = model.PetitionStatus; entity.PetitionType = model.PetitionType; entity.ServiceMembers = model.ServiceMembers; entity.LatestServiceHours = model.LatestServiceHours; entity.Remarks = model.Remarks; entity.IsDeleted = 0; _dbContext.ListOfKeyPetitioners.Add(entity); int res = _dbContext.SaveChanges(); if (res > 0) { ToLog.AddLog("添加", "成功:添加:重点上访人员信息一条数据", _dbContext); } response.SetSuccess("添加成功"); return(Ok(response)); } }