public static JsonMemberRequest ConvertToJson(this CMS.DataAccess.Member member) { try { var json = new JsonMemberRequest(); json.Id = member.Id.ToString(); json.FirstName = member.FirstName; json.MiddleName = member.MiddleName.SafeToString(); json.LastName = member.LastName.SafeToString(); json.Age = member.Age.SafeToString(); json.Gender = member.Gender.SafeToString(); json.Birthday = member.Birthday.HasValue? member.Birthday.Value.ToShortDateString(): string.Empty; json.MobilePhone = member.MobilePhone.SafeToString(); json.LandLine = member.LandLine.SafeToString(); json.Address = member.Address.SafeToString(); json.MaritalStatus = member.MaritalStatus.SafeToString(); json.NameOfSpouse = member.NameOfSpouse.SafeToString(); json.SpouseContact = member.SpouseContact.SafeToString(); json.ChildrenCount = member.ChildrenCount.SafeToString(); json.MemberStatus = member.MemberStatus.SafeToString(); json.BaptizedDate = member.BaptizedDate.HasValue? member.BaptizedDate.Value.ToShortDateString(): string.Empty; json.BaptizedPlace = member.BaptizedPlace.SafeToString(); json.BaptizedMinister = member.BaptizedMinister.SafeToString(); json.BelongsToGroups = member.BelongsToGroups.SafeToString(); json.Positions = member.Positions.SafeToString(); return(json); } catch (Exception e) { throw e; } }
// PUT api/values/5 public HttpResponseMessage Put(CMS.DataAccess.Member member) { try { CMS.DataAccess.MemberService service = new CMS.DataAccess.MemberService(); var id = service.Update(member); } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message)); } return(Request.CreateResponse(HttpStatusCode.OK)); }
// POST api/values public HttpResponseMessage Post(CMS.DataAccess.Member member) { try { member.Id = Guid.NewGuid(); CMS.DataAccess.MemberService service = new CMS.DataAccess.MemberService(); var id = service.Create(member); var response = Request.CreateResponse <CMS.DataAccess.Member>(HttpStatusCode.Created, new CMS.DataAccess.Member { Id = member.Id }); return(response); } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message)); } }