// GET: Client/Create public ActionResult Create(long?id) { var clientbl = new BLClientModel(); ViewData["SuccessClient"] = TempData["SuccessClient"]; ViewData["FailedClient"] = TempData["FailedClient"]; var martialStatus = BLMartialStatus.GetAll(); var prefixList = Enum.GetValues(typeof(ClientPrefix)) .OfType <ClientPrefix>() .Select(m => new { Text = m.ToString(), Value = (int)m }) .ToList();// Get Prefix enum list var purpose = BLPurpose.GetAll(); if (id != null) { clientbl = db.GetById(id.Value); } ViewBag.MartialStatus = new SelectList(martialStatus, "ID", "Name", clientbl.MartialStatusId); ViewBag.Prefix = new SelectList(prefixList, "Value", "Text", clientbl.Prefix); ViewBag.Purpose = new SelectList(purpose, "ID", "Name", clientbl.PurposeId); return(View(clientbl)); }
// GET: Client public ActionResult Index() { BLClientModel client = new BLClientModel(); var clients = client.GetAll(); return(View(clients)); }
public ActionResult Create(BLCases blCases) { if (ModelState.IsValid) { string lastName = string.Empty; var userId = User.Identity.GetUserId(); if (blCases.ClientId > 0) { var clientbl = clientModel.GetById(blCases.ClientId.Value); clientbl.CreatedBy = userId; clientbl.FirstName = blCases.Name; clientbl.LastName = blCases.FamilyName; clientbl.DOB = blCases.DOB.Value; clientbl.Email = blCases.Email; lastName = clientbl.LastName; var result_client = clientbl.Update(); } else { var client = new BLClientModel() { FirstName = blCases.Name, LastName = blCases.FamilyName, DOB = blCases.DOB.Value, Email = blCases.Email, CreatedBy = userId }; var result_client = client.Save(); blCases.ClientId = result_client.Item3; } blCases.CreatedBy = userId; blCases.CaseNumber = Common.GenerateRandom(6) + lastName; var result = blCases.Save(); if (result.Item1) { TempData["SuccessCase"] = result.Item2; } else { TempData["FailedCase"] = result.Item2; } return(RedirectToAction("Create")); } var cases = BLCaseType.GetAll(); ViewBag.CaseType = new SelectList(cases, "ID", "Name"); return(View(blCases)); }
public ActionResult Create(BLClientModel client) { if (ModelState.IsValid) { var userId = User.Identity.GetUserId(); client.CreatedBy = userId; if (client.ID > 0) { var result = client.Update(); if (result.Item1) { TempData["SuccessClient"] = result.Item2; } else { TempData["FailedClient"] = result.Item2; } } else { var result = client.Save(); if (result.Item1) { TempData["SuccessClient"] = result.Item2; } else { TempData["FailedClient"] = result.Item2; } } return(RedirectToAction("Create")); } var martialStatus = BLMartialStatus.GetAll(); var prefixList = Enum.GetValues(typeof(ClientPrefix)) .OfType <ClientPrefix>() .Select(m => new { Text = m.ToString(), Value = (int)m }) .ToList();// Get Prefix enum list var purpose = BLPurpose.GetAll(); ViewBag.MartialStatus = new SelectList(martialStatus, "ID", "Name", client.MartialStatusId); ViewBag.Prefix = new SelectList(prefixList, "Value", "Text", client.Prefix); ViewBag.Purpose = new SelectList(purpose, "ID", "Name", client.PurposeId); return(View(client)); }