Ejemplo n.º 1
0
        public ActionResult Details(int RegionID)
        {
            try     // handle exogenous exceptions
            {
                try // log all exceptions
                {
                    RegionBusinessModelLayers regionBusinessModelLayers = new RegionBusinessModelLayers();

                    BusinessModelLayer.RegionSingle region = regionBusinessModelLayers.GetAllRegions().FirstOrDefault(x => x.RegionID == RegionID);

                    return(View(region));
                }
                catch (Exception ex)
                {
                    BusinessLayer.ExceptionLogging exlog = new BusinessLayer.ExceptionLogging();
                    exlog.SendExcepToDB(ex);
                    throw;
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 2
0
        public ActionResult Edit(int RegionID, string sortOrder, string currentFilter, string searchString, int?page, string PgeSize)
        {
            try     // handle exogenous exceptions
            {
                try // log all exceptions
                {
                    ViewBag.CurrentSort = sortOrder;
                    ViewBag.RegionID    = RegionID;

                    BusinessLayer.Validation pge      = new BusinessLayer.Validation();
                    List <SelectListItem>    PgeSizes = pge.PageSize();

                    //Assigning generic list to ViewBag
                    ViewBag.PgeSizeList = PgeSizes;

                    if (searchString != null)
                    {
                        page = 1;
                    }
                    else
                    {
                        searchString = currentFilter;
                    }

                    ViewBag.CurrentFilter = searchString;

                    //REGION TABLE MASTER
                    BusinessModelLayer.Region.RegionMasterDetailModel pageModel = new BusinessModelLayer.Region.RegionMasterDetailModel();
                    RegionBusinessModelLayers      regionBusinessModelLayers    = new RegionBusinessModelLayers();
                    Region.RegionMasterDetailModel regionMasterDetailModel      = new Region.RegionMasterDetailModel();

                    pageModel.Region = regionBusinessModelLayers.GetAllRegions().FirstOrDefault(x => x.RegionID == RegionID);

                    int pageSize = 10;
                    if (PgeSize != null)
                    {
                        Int32.TryParse(PgeSize, out pageSize);
                    }
                    ViewBag.PgeSize = pageSize;

                    int pageNumber = (page ?? 1);


                    //TERRITORIES DETAIL BEGIN

                    ViewBag.RegionIDSortParm = String.IsNullOrEmpty(sortOrder) ? "RegionID_desc" : "";
                    TerritoriesBusinessModelLayers territoriesBusinessModelLayers = new TerritoriesBusinessModelLayers();

                    List <BusinessModelLayer.Vwterritories> territoriess = territoriesBusinessModelLayers.GetAllVwterritoriess().FindAll(x => x.RegionID == RegionID).ToList();

                    if (!String.IsNullOrEmpty(searchString))
                    {
                        territoriess = territoriess.Where(s => s.RegionID == RegionID && s.TerritoryDescription.ToString().ToLower().Contains(searchString.ToLower())).ToList();
                    }

                    switch (sortOrder)
                    {
                    case "RegionID_desc":
                        territoriess = territoriess.OrderByDescending(s => s.RegionID).ToList();
                        break;

                    default:      // RegionID ascending
                        territoriess = territoriess.OrderBy(s => s.RegionID).ToList();
                        break;
                    }
                    pageModel.TerritoriesVwDetl = territoriess.ToPagedList(pageNumber, pageSize);

                    //TERRITORIES DETAIL END
                    return(View(pageModel));
                }
                catch (Exception ex)
                {
                    BusinessLayer.ExceptionLogging exlog = new BusinessLayer.ExceptionLogging();
                    exlog.SendExcepToDB(ex);
                    throw;
                }
            }
            catch (Exception)
            {
                throw;
            }
        }