public CommunityMember convertMainObjectToCommunityMember(MainObjectFromCsvFileInfo mainObject) { CommunityMember communityMemberVm = new CommunityMember(); if(string.IsNullOrWhiteSpace(mainObject.FatherFirstName) && string.IsNullOrWhiteSpace(mainObject.FatherLastName)) { communityMemberVm.FirstName = string.IsNullOrWhiteSpace(mainObject.MotherFirstName) ? "N/A" : mainObject.MotherFirstName; communityMemberVm.LastName = string.IsNullOrWhiteSpace(mainObject.MotherLastName) ? "N/A" : mainObject.MotherLastName; } else { communityMemberVm.FirstName = string.IsNullOrWhiteSpace(mainObject.FatherFirstName)? "N/A" : mainObject.FatherFirstName; communityMemberVm.LastName = string.IsNullOrWhiteSpace(mainObject.FatherLastName)? "N/A" : mainObject.FatherLastName; communityMemberVm.SpouseFirstName = string.IsNullOrWhiteSpace(mainObject.MotherFirstName)? "N/A" : mainObject.MotherFirstName; communityMemberVm.SpouseLastName = string.IsNullOrWhiteSpace(mainObject.MotherLastName)? "N/A" : mainObject.MotherLastName; } communityMemberVm.PhoneNumber = mainObject.FatherPhone; communityMemberVm.SpousePhoneNumber = mainObject.MotherPhone; communityMemberVm.Email = "*****@*****.**"; if (mainObject.Children != null && mainObject.Children.Count() > 0) { communityMemberVm.Children = new List<Child>(); for (int i = 0; i < mainObject.Children.Count(); i++) { var mainObjectChild = mainObject.Children[i]; Child child = new Child(); child.FirstName = mainObjectChild.ChildFirstName; child.LastName = string.IsNullOrWhiteSpace(communityMemberVm.LastName) ? "" : communityMemberVm.LastName; child.Gender = mainObjectChild.Gender; child.DateOfBirth = new Extentions().getDobFromAge(mainObjectChild.Age); communityMemberVm.Children.Add(child); } } return communityMemberVm; }
public ActionResult AddMember(CommunityMember cMemb) { if (ModelState.IsValid) { return Json(membersRepo.AddMember(cMemb)); } return Json(ErrorMessages.getErrorFieldsEmptyServerResponse()); }
public ServerResponse<string, string, CommunityMemberVm> AddMember(CommunityMember cMemb) { try { baseRepo.Add<CommunityMember>(cMemb); CommunityMemberVm cmvm = new CommunityMemberVm(cMemb, false); return new ServerResponse<string, string, CommunityMemberVm>(ErrorMessages.SuccessString, null, cmvm); } catch (Exception e) { return new ServerResponse<string, string, CommunityMemberVm>(ErrorMessages.ErrorString, ErrorMessages.ErrMsg_Generic, null); } }
public ServerResponse<string, string, CommunityMemberVm> UpdateMember(CommunityMember model) { try { baseRepo.Update<CommunityMember>(model); CommunityMemberVm cmvm = new CommunityMemberVm(model, false); return new ServerResponse<string, string, CommunityMemberVm>(ErrorMessages.SuccessString, null, cmvm); } catch (Exception e) { return new ServerResponse<string, string, CommunityMemberVm>(ErrorMessages.ErrorString, ErrorMessages.ErrMsg_Generic, null); } }
public CommunityMemberVm(CommunityMember cm, bool getNestedListData) { CommunityMemberId = cm.CommunityMemberId; FirstName = cm.FirstName; LastName = cm.LastName; SpouseFirstName = cm.SpouseFirstName; SpouseLastName = cm.SpouseLastName; SpousePhoneNumber = cm.SpousePhoneNumber; PhoneNumber = cm.PhoneNumber; Email = cm.Email; Gender = cm.Gender; DateOfBirth = cm.DateOfBirth; Street1 = cm.Street1; Street2 = cm.Street2; City = cm.City; State = cm.State; ZipCode = cm.ZipCode; Age = cm.Age; NumberOfIndividualsInFamily = cm.NumberOfIndividualsInFamily; NumberOfChildren = cm.NumberOfChildren; FullName = cm.FullName; if (getNestedListData) { this.Children = new List<ChildVm>(); if (cm.Children != null && cm.Children.Count() > 0) { foreach (var child in cm.Children) { ChildVm cvm = new ChildVm(child, true); this.Children.Add(cvm); } } } }
public ActionResult UpdateMember(CommunityMember model) { if (ModelState.IsValid) { return Json(membersRepo.UpdateMember(model)); } return Json(ErrorMessages.getErrorFieldsEmptyServerResponse()); }