public PartialViewResult InstitutionList(InstitutionListViewModel obj) { var model = new InstitutionListViewModel(); MyId = Convert.ToInt32(User.Identity.GetUserId()); model.Search = obj.Search; model.role = ""; if (User.IsInRole("admin") || User.IsInRole("seeAllUsers")) { model.role = "seeAllUsers"; } else if (User.IsInRole("RM")) { model.role = "RM"; } else if (User.IsInRole("UZ_dir")) { model.role = "UZ_dir"; } model.assigned_insts = AssignedInstitutionRep.FindBy(i => i.cuser_id == MyId).ToList(); model.RegionId = obj.RegionId; model.paging.CurrentPage = obj.CurrentPage; model.UserId = obj.UserId; model.InstTypeId = obj.InstTypeId; model.HasPromotion = obj.HasPromotion; model.Institutions = InstitutionRep.FindBy(model.predicate).OrderBy(i => i.name); return(PartialView(model)); }
// GET: Institutions public ActionResult InstitutionsOrEmployees(InstitutionListViewModel obj, string StartMode) { ViewBag.ChooseDepartment = new SelectList(EmpDepartmentRep.GetAll(), "id", "name"); ViewBag.ChoosePosition = new SelectList(EmpPositionRep.GetAll(), "id", "name"); ViewBag.ChooseSpeciality = new SelectList(EmpSpecialityRep.GetAll(), "id", "name"); ViewBag.ChooseCallTemplate = new SelectList(CallTemplateRep.GetAll(), "id", "name"); ViewBag.ChoosePromotion = new SelectList(PromotionRep.GetAll(), "id", "name"); ViewBag.SIPServerPath = CurrentVarsRep.GetAll().First().SIPServerPath; MyId = Convert.ToInt32(User.Identity.GetUserId()); var show_all_regions = CUserRep.FindBy(i => i.id == MyId).First().show_all_regions; var MyCountryCode = RegionRep.Get((int)CUserRep.FindBy(i => i.id == MyId).FirstOrDefault().base_region_id).country_code; if (User.IsInRole("admin") || User.IsInRole("DD")) { regions = RegionRep.FindBy(i => (bool)i.is_actual == true).OrderBy(k => k.name).ToList(); } else if ((bool)show_all_regions) { regions = RegionRep.FindBy(i => (bool)i.is_actual == true && i.country_code.Equals(MyCountryCode)).OrderBy(k => k.name).ToList(); } else { regions = AssignedRegionRep.FindBy(i => i.cuser_id == MyId).Select(i => new Region { id = (int)i.region_id, name = i.Region.name }).ToList(); } if (regions.Count() == 0) { int regId = (int)CUserRep.FindBy(i => i.id == MyId).First().base_region_id; regions.Add(RegionRep.FindBy(r => r.id == regId).First()); } ViewBag.ChooseRegion = new SelectList(regions, "id", "name" /*regions.First().id*/); ViewBag.ChooseInstType = new SelectList(InstTypeRep.FindBy(i => i.id == 2 || i.id == 3), "id", "name", 2); var model = new InstitutionListViewModel(); model.CurrentPage = obj.CurrentPage; model.UserId = MyId; model.RegionId = regions.First().id; model.InstTypeId = 2; model.StartMode = StartMode; ViewBag.CurrentPage = model.CurrentPage; return(View("institutions", model)); }
public ActionResult CallCenter(InstitutionListViewModel obj) { return(InstitutionsOrEmployees(obj, "CallCenterMode")); }
public ActionResult Employees(InstitutionListViewModel obj) { return(InstitutionsOrEmployees(obj, "EmployeeMode")); }