public ActionResult Index(RegionViewModel regionViewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    bool isDuplicate = false;
                    isDuplicate = regionViewModel.CheckDuplicate(regionViewModel);

                    if (isDuplicate)
                    {
                        regionViewModel.GetRegionDetails();
                        ViewBag.Message = "Region Already Exists";
                        return(View("Index", regionViewModel));
                    }
                    else
                    {
                        regionViewModel.Region = regionViewModel.Region == null ? "" : regionViewModel.Region.Trim();
                        regionViewModel.AddRegion(regionViewModel);
                        regionViewModel.GetRegionDetails();
                        ViewBag.Message = "New Region Added Successfully";
                        return(View("Index", regionViewModel));
                    }
                }
                regionViewModel.GetRegionDetails();
                return(View(regionViewModel));
            }
            catch (Exception ex)
            {
                errorlogviewmodel = new ErrorLogViewModel();
                errorlogviewmodel.LogError(ex);
                return(View("Error"));
            }
        }
Exemplo n.º 2
0
        public ActionResult Index()
        {
            try
            {
                string urlPart = @"/Project";
                if (System.Web.HttpContext.Current.Request.UrlReferrer.ToString().IndexOf(urlPart) > 0)
                {
                    Session["PreviousURL"] = System.Web.HttpContext.Current.Request.UrlReferrer;
                }

                RegionViewModel regionViewModel = new RegionViewModel();
                //if (id == null)
                //    id = (int)TempData["ProjectId"];
                regionViewModel.GetRegionDetails();
                regionViewModel.GetScreenAccessRights("Region Details");
                //appVersionViewModel.ProjectID = (int)id;


                //int clientId;
                //string projectName;

                //CommonFunctions comfuns = new CommonFunctions();

                //comfuns.GetProjectName((int)id, out clientId, out projectName);
                //applicationViewModel.ClientId = clientId;
                //applicationViewModel.ProjectName = projectName;

                //applicationViewModel.ClientName = comfuns.GetClientName(clientId);

                return(View(regionViewModel));
            }
            catch (Exception ex)
            {
                errorlogviewmodel = new ErrorLogViewModel();
                errorlogviewmodel.LogError(ex);
                return(View("Error"));
            }
        }