コード例 #1
0
        public MasterBranch GetDetail(int id)
        {
            MasterBranch result = _tsicsContext.MasterBranch
                                  .SingleOrDefault(s => s.MasterBranchId.Equals(id));

            return(result);
        }
コード例 #2
0
        // GET: Admin/MasterBranch/Details/5
        public ActionResult Details(int id)
        {
            if (Common.CheckAdmin())
            {
                return(RedirectToAction("Login", "Default"));
            }

            MasterBranch masterBranch = _masterBranchService.GetDetail(id);
            MasterArea   masterArea   = _masterAreaService.GetDetail(Convert.ToInt32(masterBranch.MasterAreaId));

            ViewBag.MasterAreaMapping = masterArea.Name;
            return(View(masterBranch));
        }
コード例 #3
0
        public ActionResult DeleteConfirmed(int id)
        {
            ViewBag.alertMessage = "Master Branch Deleted";
            if (Common.CheckAdmin())
            {
                return(RedirectToAction("Login", "Default"));
            }

            MasterBranch masterBranch = _masterBranchService.GetDetail(id);

            masterBranch.Status = 2;

            _masterBranchService.Edit(masterBranch);
            return(RedirectToAction("Index"));
        }
コード例 #4
0
        // GET: Admin/MasterBranch/Delete/5
        public ActionResult Delete(int id)
        {
            if (Common.CheckAdmin())
            {
                return(RedirectToAction("Login", "Default"));
            }

            MasterBranch masterBranch = _masterBranchService.GetDetail(id);

            if (masterBranch == null)
            {
                return(HttpNotFound());
            }
            return(View(masterBranch));
        }
コード例 #5
0
        public ActionResult Edit(MasterBranch masterBranch)
        {
            ViewBag.alertMessage = "Master Branch Data Has Been Upgraded";
            if (Common.CheckAdmin())
            {
                return(RedirectToAction("Login", "Default"));
            }

            if (ModelState.IsValid)
            {
                _masterBranchService.Edit(masterBranch);
                return(RedirectToAction("Index"));
            }
            return(View(masterBranch));
        }
コード例 #6
0
        public ActionResult Create([Bind(Include = "MasterBranchId,MasterAreaId,Name,Status")] MasterBranch masterBranch)
        {
            if (Common.CheckAdmin())
            {
                return(RedirectToAction("Login", "Default"));
            }
            ViewBag.alertMessage = "Master Branch Data Has Been Created";
            if (ModelState.IsValid)
            {
                _masterBranchService.Add(masterBranch);

                return(RedirectToAction("Index"));
            }

            return(View(masterBranch));
        }
コード例 #7
0
        // GET: Admin/MasterBranch/Edit/5
        public ActionResult Edit(int id)
        {
            if (Common.CheckAdmin())
            {
                return(RedirectToAction("Login", "Default"));
            }
            ViewBag.ListMasterBranch = _masterBranchService.GetList();
            MasterBranch masterBranch = _masterBranchService.GetDetail(id);

            ViewBag.ListMasterArea = _masterAreaService.GetListActive();
            if (masterBranch == null)
            {
                return(HttpNotFound());
            }

            return(View(masterBranch));
        }
コード例 #8
0
 public MasterBranch Edit(MasterBranch masterBranch)
 {
     _tsicsContext.Entry(masterBranch).State = EntityState.Modified;
     _tsicsContext.SaveChanges();
     return(masterBranch);
 }
コード例 #9
0
 public MasterBranch Add(MasterBranch masterBranch)
 {
     _tsicsContext.MasterBranch.Add(masterBranch);
     _tsicsContext.SaveChanges();
     return(masterBranch);
 }
コード例 #10
0
        // GET: Admin/MasterBranch
        public ActionResult Index(string sortOrder, string currentFilter, string searchString, int?page)
        {
            if (Common.CheckAdmin())
            {
                return(RedirectToAction("Login", "Default"));
            }
            //ViewBag.alertMessage = null;
            //int pageSize = 10;
            //int pageNumber = (page ?? 1);

            //List<MasterBranch> ListMasterBranch = new List<MasterBranch>();
            //ListMasterBranch = MasterBranchService.GetList();

            //return View(ListMasterBranch.ToPagedList(pageNumber, pageSize));


            ViewBag.CurrentSort    = sortOrder;
            ViewBag.DateSortParm   = String.IsNullOrEmpty(sortOrder) ? "IdDesc" : "";
            ViewBag.TitleSortParm  = sortOrder == "Name" ? "NameDesc" : "Name";
            ViewBag.StatusSortParm = sortOrder == "AreaId" ? "AreaIdDesc" : "AreaId";

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

            ViewBag.CurrentFilter = searchString;

            var masterBranch = _masterBranchService.GetQueryableList();

            if (!String.IsNullOrEmpty(searchString))
            {
                masterBranch = masterBranch.Where(branch =>
                                                  branch.Name.Contains(searchString)
                                                  );
            }
            switch (sortOrder)
            {
            case "IdDesc":
                masterBranch = masterBranch.OrderByDescending(t => t.MasterBranchId);
                break;

            case "Name":
                masterBranch = masterBranch.OrderBy(t => t.Name);
                break;

            case "NameDesc":
                masterBranch = masterBranch.OrderByDescending(t => t.Name);
                break;

            case "AreaId":
                masterBranch = masterBranch.OrderBy(t => t.MasterAreaId);
                break;

            case "AreaIdDesc":
                masterBranch = masterBranch.OrderByDescending(t => t.MasterAreaId);
                break;

            default:
                masterBranch = masterBranch.OrderBy(s => s.MasterBranchId);
                break;
            }

            List <MasterBranch> masterBranchList = new List <MasterBranch>();

            if (masterBranch != null)
            {
                foreach (var branch in masterBranch)
                {
                    if (_masterAreaService.GetDetail(branch.MasterAreaId) != null)
                    {
                        MasterBranch masterBranchData = new MasterBranch()
                        {
                            MasterBranchId = branch.MasterBranchId,
                            Name           = _masterAreaService.GetDetail(branch.MasterAreaId).Name
                        };
                        masterBranchList.Add(masterBranchData);
                    }
                    else
                    {
                        MasterBranch masterBranchData = new MasterBranch()
                        {
                            MasterBranchId = branch.MasterBranchId,
                            Name           = ""
                        };
                        masterBranchList.Add(masterBranchData);
                    }
                }
            }
            ViewBag.MasterArea = masterBranchList;

            int pageSize   = 999999999;
            int pageNumber = (page ?? 1);

            return(View(masterBranch.ToPagedList(pageNumber, pageSize)));
        }