Example #1
0
        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);
                        applicationViewModel.GetScreenAccessRights("Application Details");
                        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);
                        applicationViewModel.GetScreenAccessRights("Application Details");
                        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);
                applicationViewModel.GetScreenAccessRights("Application Details");

                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");
            }
        }