public ActionResult Edit(MemberRegistration objMember) { if (string.IsNullOrEmpty(objMember.MemberFirstName)) { ModelState.AddModelError("Error", "Please enter First Name"); } else if (string.IsNullOrEmpty(objMember.MemberLastName)) { ModelState.AddModelError("Error", "Please enter Last Name"); } else if (string.IsNullOrEmpty(objMember.MemberAddress)) { ModelState.AddModelError("Error", "Please enter Member Address"); } else if (string.IsNullOrEmpty(objMember.MembershipAmount.ToString())) { ModelState.AddModelError("Error", "Please enter Membership Amount"); } else if (string.IsNullOrEmpty(Convert.ToString(objMember.MembershipDate))) { ModelState.AddModelError("Error", "Please enter Membership Date"); } else { // ObjMember.CreatedBy = Session["UserName"].ToString(); objMember.CreateBy = "Avi"; int MemberId = objRegisterMember.UpdateMember(objMember); if (MemberId > 0) { ViewBag.Text = "Member updated Successfully."; } else { TempData["Message"] = "Some thing went wrong while Member updated."; } return(RedirectToAction("Edit")); } return(View(objMember)); }
public ActionResult Edit(MemberRegistrationDTO objMR, string actionType) { if (actionType == "Update") { if (string.IsNullOrEmpty(objMR.MemberFName)) { ModelState.AddModelError("Error", "Please enter First Name"); } else if (string.IsNullOrEmpty(objMR.MemberMName)) { ModelState.AddModelError("Error", "Please enter Middle Name"); } else if (string.IsNullOrEmpty(objMR.MemberLName)) { ModelState.AddModelError("Error", "Please enter Last Name"); } else if (string.IsNullOrEmpty(Convert.ToString(objMR.DOB))) { ModelState.AddModelError("Error", "Please select Birth Date"); } else if (string.IsNullOrEmpty(Convert.ToString(objMR.JoiningDate))) { ModelState.AddModelError("Error", "Please select Joining Date"); } else if (string.IsNullOrEmpty(objMR.Age)) { ModelState.AddModelError("Error", "Please enter Age"); } else if (string.IsNullOrEmpty(objMR.EmailID)) { ModelState.AddModelError("Error", "Please enter EmailID"); } else if (string.IsNullOrEmpty(Convert.ToString(objMR.WorkouttypeID))) { ModelState.AddModelError("Error", "Please select Workouttype"); } else if (string.IsNullOrEmpty(Convert.ToString(objMR.PlantypeID))) { ModelState.AddModelError("Error", "Please select Plan"); } else if (string.IsNullOrEmpty(objMR.Contactno)) { ModelState.AddModelError("Error", "Please enter Contactno"); } else if (string.IsNullOrEmpty(objMR.Address)) { ModelState.AddModelError("Error", "Please enter Address"); } else if (string.IsNullOrEmpty(Convert.ToString(objMR.Amount))) { ModelState.AddModelError("Error", "Amount Cannot be Empty"); } else { string[] parttime = objMR.DOB.ToString().Split('-'); int year1 = Convert.ToInt32(objMR.DOB.Value.Year); int month1 = Convert.ToInt32(objMR.DOB.Value.Month); int day1 = Convert.ToInt32(objMR.DOB.Value.Day); DateTime birthdate = new DateTime(year1, month1, day1); objMR.DOB = birthdate; string[] joing = objMR.JoiningDate.ToString().Split('-'); int year2 = Convert.ToInt32(objMR.JoiningDate.Value.Year); int month2 = Convert.ToInt32(objMR.JoiningDate.Value.Month); int day2 = Convert.ToInt32(objMR.JoiningDate.Value.Day); DateTime joining = new DateTime(year2, month2, day2); objMR.JoiningDate = joining; objMR.Createdby = Convert.ToInt32(Session["UserID"]); int MemberID = objRegMem.UpdateMember(objMR); // Insert into MemberDetails if (MemberID > 0) { int payresult = PayUpdate(objMR, MemberID); TempData["MessageUpdate"] = "Member Created Successfully."; } return(RedirectToAction("Index")); } return(RedirectToAction("Index")); } else { return(RedirectToAction("Index")); } }