public ActionResult Edit(HouseHoldMemberDetails member, string submit) { try { int age = DateTime.Now.Year - DateTime.Parse(member.DateOfBirth.ToString()).Year; if (age > 125 && age < 0) { ModelState.AddModelError("DateOfBirth", "Age cannot be more than 125 or less than 0"); } var list = httpHelper.GetCall <List <HouseHoldMemberDetails> >("api/Home/GetAllHouseHoldMembers").Result; var FirstMemberOfFamily = list.AsQueryable().Where(x => x.isFirstMember == true && x.FamilyId == member.FamilyId).FirstOrDefault(); int ageOfFirstMember = DateTime.Now.Year - DateTime.Parse(FirstMemberOfFamily.DateOfBirth.ToString()).Year; if (age > ageOfFirstMember) { ModelState.AddModelError("DateOfBirth", "Age cannot be greater than First Member Of Family"); } if (ModelState.IsValid) { httpHelper.PostData <HouseHoldMemberDetails>(member, "api/Home/UpdateMember"); return(View("SearchApplication")); } return(View(member)); } catch (Exception ex) { return(View("Error"));; } }
public ActionResult CreateApplication(HouseHoldMemberDetails houseHoldMemberDetails, string submit) { try { if (ModelState.IsValid) { int age = DateTime.Now.Year - DateTime.Parse(houseHoldMemberDetails.DateOfBirth.ToString()).Year; if (age > 125 && age < 0) { ModelState.AddModelError("DateOfBirth", "Age cannot be more than 125 or not after current year"); } int userId = int.Parse(Session["UserId"].ToString()); var list = httpHelper.GetCall <List <HouseHoldMemberDetails> >("api/Home/GetHouseHoldMembers?id=" + userId).Result; if (list.Count == 5) { ViewBag.CountError = "Family cannot have more than 5 members"; return(View()); } var FirstMemberOfFamily = list.AsQueryable().Where(x => x.isFirstMember == true && x.UserId == userId).FirstOrDefault(); int ageOfFirstMember = DateTime.Now.Year - DateTime.Parse(FirstMemberOfFamily.DateOfBirth.ToString()).Year; if (age > ageOfFirstMember) { ModelState.AddModelError("DateOfBirth", "Age cannot be greater than First Member Of Family"); } if (ModelState.IsValid) { switch (submit) { case "AddMember": houseHoldMemberDetails.UserId = int.Parse(Session["UserId"].ToString()); httpHelper.PostData <HouseHoldMemberDetails>(houseHoldMemberDetails, "api/Home/PostHouseHoldMember"); break; case "Save&Exit": Session["HouseholdMemberDetails"] = houseHoldMemberDetails; break; } return(RedirectToAction("Index")); } else { return(View()); } } else { return(View()); } } catch (Exception ex) { return(View("Error"));; } }
public ActionResult CreateApplication() { try { HouseHoldMemberDetails retainedId = new HouseHoldMemberDetails(); if (Session["HouseholdMemberDetails"] != null) { retainedId = (HouseHoldMemberDetails)Session["HouseholdMemberDetails"]; } return(View(retainedId)); } catch (Exception ex) { return(View("Error"));; } }
public ActionResult View(int data) { try { var houseHoldMembers = httpHelper.GetCall <List <HouseHoldMemberDetails> >("api/Home/GetAllHouseHoldMembers").Result; HouseHoldMemberDetails member = new HouseHoldMemberDetails(); member = houseHoldMembers.AsQueryable().Where(x => x.MemberId == data).FirstOrDefault(); return(View(member)); } catch (Exception ex) { return(View("Error"));; } }