public FamousPersonInfo Save([FromBody] FamousPersonInfo value) { if (value != null && ModelState.IsValid) { return(FamousPersonService.Save(value)); } else { throw new CustomerApiException(HttpStatusCode.NotAcceptable, 1, "字段值不合法"); } }
public void Update(int id, [FromBody] FamousPersonInfo value) { if (value != null && ModelState.IsValid) { value.FamousPersonId = id; FamousPersonService.Update(value); //不处理图片文件了 } else { throw new CustomerApiException(HttpStatusCode.NotAcceptable, 1, "字段值不合法"); } }
public void Update(FamousPersonInfo famousePersonInfo) { famousPersonRepository.Update(FamousPersonConverter.ConvertToDo(famousePersonInfo), p => p.FamousPersonId); personTypeRelationRepository.DeleteByLinq(p => p.FamousPersonId == famousePersonInfo.FamousPersonId); var typeIds = famousePersonInfo.PersonTypeIds; foreach (var typeId in typeIds) { personTypeRelationRepository.Save(new PersonTypeRelation() { FamousPersonTypeId = typeId, FamousPersonId = famousePersonInfo.FamousPersonId }); } }
public FamousPersonInfo Save(FamousPersonInfo famousePersonInfo) { var person = famousPersonRepository.Save(FamousPersonConverter.ConvertToDo(famousePersonInfo)); var typeIds = famousePersonInfo.PersonTypeIds; foreach (var typeId in typeIds) { personTypeRelationRepository.Save(new PersonTypeRelation() { FamousPersonTypeId = typeId, FamousPersonId = person.FamousPersonId }); } famousePersonInfo.FamousPersonId = person.FamousPersonId; return(famousePersonInfo); }
public static FamousPerson ConvertToDo(FamousPersonInfo famousPersonInfo) { if (famousPersonInfo == null) { return(null); } var person = new FamousPerson() { BornDate = famousPersonInfo.BornDate, BornPlace = famousPersonInfo.BornPlace, BornX = famousPersonInfo.BornX, BornY = famousPersonInfo.BornY, DeadDate = famousPersonInfo.DeadDate, FamousPersonId = famousPersonInfo.FamousPersonId, Province = famousPersonInfo.Province, Gender = famousPersonInfo.Gender, Nation = famousPersonInfo.Nation, PersonName = famousPersonInfo.PersonName, }; return(person); }
public static FamousPersonInfo ConvertToDto(FamousPerson famousPerson, IEnumerable <Int32> typeIds) { if (famousPerson == null) { return(null); } var personInfo = new FamousPersonInfo() { BornDate = famousPerson.BornDate, BornPlace = famousPerson.BornPlace, BornX = famousPerson.BornX, BornY = famousPerson.BornY, DeadDate = famousPerson.DeadDate, FamousPersonId = famousPerson.FamousPersonId, Province = famousPerson.Province, Gender = famousPerson.Gender, Nation = famousPerson.Nation, PersonName = famousPerson.PersonName, PersonTypeIds = typeIds }; return(personInfo); }