Esempio n. 1
0
        public JsonResult GetBranchesByOrganization(int?id)
        {
            var branchList = _branchManager.GetAll(c => true);

            if (id != null)
            {
                branchList = branchList.Where(c => c.OrganizationId == id).ToList();
            }

            return(Json(branchList, JsonRequestBehavior.AllowGet));
        }
        private List <SelectListItem> BranchList()
        {
            List <SelectListItem> branchList = _iBranchManager.GetAll()
                                               .Select(b => new SelectListItem
            {
                Value = b.Id.ToString(),
                Text  = b.Name
            }).ToList();

            return(branchList);
        }
Esempio n. 3
0
        public void GetAll()
        {
            UnityResolver.Register();
            IBranchManager BranchManager = UnityResolver.Resolve <IBranchManager>();

            List <Branch> list = BranchManager.GetAll();

            foreach (Branch branch in list)
            {
                Console.WriteLine("Ashan Tharuka : " + branch.Address);
            }
        }
Esempio n. 4
0
        public ActionResult Create(Branch branch)
        {
            ViewBag.OrganizationList = GetOrganizations();

            if (ModelState.IsValid && branch != null)
            {
                ModelState.Clear();
                try
                {
                    var BranchList = _branchManager.GetAll(c => true);

                    int BranchExist = BranchList
                                      .Where(c => c.OrganizationId == branch.OrganizationId)
                                      .Where(c => c.ShortName == branch.ShortName)
                                      .Count();

                    if (BranchExist > 0)
                    {
                        branch.ShortName = null;
                        ModelState.AddModelError("ShortName",
                                                 "Short name for the branch already exists for the organization");
                    }
                    else
                    {
                        if (_branchManager.Add(branch))
                        {
                            ViewBag.Msg = "Branch added successfully!";
                            return(View());
                        }
                    }
                }
                catch (Exception exception)
                {
                    Console.WriteLine(exception.Message);
                }
            }

            return(View(branch));
        }
Esempio n. 5
0
        public JsonResult BranchAutoComplete(string prefix)
        {
            var branches   = _iBranchManager.GetAll().ToList();
            var branchList = (from c in branches.ToList()
                              where c.BranchName.ToLower().Contains(prefix.ToLower())
                              select new
            {
                label = c.BranchName,
                val = c.BranchId
            }).ToList();

            return(Json(branchList));
        }
        public bool Remove(Organization entity)
        {
            /* Removin associated branches of the organization */
            var branchList = _branchManager.GetAll(c => c.OrganizationId == entity.Id);

            if (branchList.Count > 0)
            {
                foreach (var branch in branchList)
                {
                    _branchManager.Remove(branch);
                }
            }
            return(_repository.Remove(entity));
        }
Esempio n. 7
0
        // Indivisual Organization Details
        public ActionResult Details(int?id)
        {
            if (Session["username"] == null)
            {
                return(RedirectToAction("HomePage", "Home"));
            }

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Organization organization = organizationManager.GetById(id);

            if (organization == null)
            {
                return(HttpNotFound());
            }

            ViewBag.branchlist = branchManager.GetAll().Where(c => c.OrganizationId == id).ToList();
            return(View(organization));
        }
        // GET: Branch
        public ActionResult Index()
        {
            var branches = _branchManager.GetAll();

            return(View(branches.ToList()));
        }