public ActionResult Edit(ApplicationViewModel applicationViewModel) { try { if (ModelState.IsValid) { bool isduplicate = false; applicationViewModel.ApplicationName = applicationViewModel.ApplicationName.Trim(); isduplicate = applicationViewModel.CheckDuplicate(applicationViewModel); if (isduplicate) { ModelState.AddModelError("ApplicationName", "Application already exists"); applicationViewModel.GetVersions(applicationViewModel); applicationViewModel.BankTypeList = applicationViewModel.GetEnumList <ApplicationViewModel.BankTypes>(); return(View("Edit", applicationViewModel)); } applicationViewModel.UpdateApplication(applicationViewModel); return(RedirectToAction("Index", "Application")); } applicationViewModel.GetVersions(applicationViewModel); applicationViewModel.BankTypeList = applicationViewModel.GetEnumList <ApplicationViewModel.BankTypes>(); return(View(applicationViewModel)); } catch (Exception ex) { errorlogviewmodel = new ErrorLogViewModel(); errorlogviewmodel.LogError(ex); return(View("Error")); } }
public ActionResult Index(ApplicationViewModel applicationViewModel) { try { CommonFunctions comfuns = new CommonFunctions(); if (ModelState.IsValid) { applicationViewModel.ApplicationName = applicationViewModel.ApplicationName.Trim(); bool isDuplicate = false; isDuplicate = applicationViewModel.CheckDuplicate(applicationViewModel); if (isDuplicate) { applicationViewModel.GetApplicationDetails(applicationViewModel.ProjectID); ViewBag.Message = "Application Already Exists"; ViewData["Applicationviewmodel1"] = (IEnumerable <ApplicationViewModel>) from u in applicationViewModel.lstApplication join b in applicationViewModel.lstAppVersion on u.AppVersion equals b.Id join bp in applicationViewModel.BankTypeList on u.BankType equals bp.Value select new ApplicationViewModel { ApplicationID = u.ApplicationID, ApplicationName = u.ApplicationName, AppVersion = b.AppVersion, BankTypeName = bp.Key }; comfuns.GetProjectNameForDuplicateCheck(applicationViewModel.ProjectID, applicationViewModel.ClientId, applicationViewModel.ProjectName); applicationViewModel.ClientName = comfuns.GetClientName(applicationViewModel.ClientId); return(View(applicationViewModel)); } else { applicationViewModel.AddApplication(applicationViewModel); TempData["ProjectId"] = applicationViewModel.ProjectID; applicationViewModel.GetApplicationDetails(applicationViewModel.ProjectID); ViewBag.Message = "New Application Added Successfully"; ViewData["Applicationviewmodel1"] = (IEnumerable <ApplicationViewModel>) from u in applicationViewModel.lstApplication join b in applicationViewModel.lstAppVersion on u.AppVersion equals b.Id join bp in applicationViewModel.BankTypeList on u.BankType equals bp.Value select new ApplicationViewModel { ApplicationID = u.ApplicationID, ApplicationName = u.ApplicationName, AppVersion = b.AppVersion, BankTypeName = bp.Key }; comfuns.GetProjectNameForDuplicateCheck(applicationViewModel.ProjectID, applicationViewModel.ClientId, applicationViewModel.ProjectName); applicationViewModel.ClientName = comfuns.GetClientName(applicationViewModel.ClientId); return(View(applicationViewModel)); } } applicationViewModel.GetApplicationDetails(applicationViewModel.ProjectID); ViewData["Applicationviewmodel1"] = (IEnumerable <ApplicationViewModel>) from u in applicationViewModel.lstApplication join b in applicationViewModel.lstAppVersion on u.AppVersion equals b.Id join bp in applicationViewModel.BankTypeList on u.BankType equals bp.Value select new ApplicationViewModel { ApplicationID = u.ApplicationID, ApplicationName = u.ApplicationName, AppVersion = b.AppVersion, BankTypeName = bp.Key }; comfuns.GetProjectNameForDuplicateCheck(applicationViewModel.ProjectID, applicationViewModel.ClientId, applicationViewModel.ProjectName); applicationViewModel.ClientName = comfuns.GetClientName(applicationViewModel.ClientId); int clientId; string projectName; comfuns.GetProjectName(applicationViewModel.ProjectID, out clientId, out projectName); applicationViewModel.ClientId = clientId; applicationViewModel.ProjectName = projectName; applicationViewModel.ClientName = comfuns.GetClientName(clientId); return(View(applicationViewModel)); } catch (Exception ex) { errorlogviewmodel = new ErrorLogViewModel(); errorlogviewmodel.LogError(ex); return(View("Error")); } }