public ActionResult StaffList() { var model = new StaffListModel(); int MyId = Convert.ToInt32(User.Identity.GetUserId()); model.ParamNames = UserParamNameRep.FindBy(i => i.is_actual == true).OrderBy(i => i.param_order).ToList(); var MyBaseRegion = CUserRep.FindBy(i => i.id == MyId).First().base_region_id; var MyCountryCode = RegionRep.FindBy(i => i.id == MyBaseRegion).First().country_code; if (User.IsInRole("admin")) { model.ActualParamsValues = ActualUserParamValueRep.FindBy(i => i.user_department_id == 2).OrderBy(i => i.userName).ToList(); } else if (User.IsInRole("seeAllUsers") && User.IsInRole("CanSeeUserFinance")) { model.ActualParamsValues = ActualUserParamValueRep.FindBy(i => i.user_department_id == 2 && i.country_code.Equals(MyCountryCode)).OrderBy(i => i.userName).ToList(); } else if (User.IsInRole("CanSeeUserFinance")) { model.ActualParamsValues = ActualUserParamValueRep.FindBy(i => i.boss_id == MyId || i.top_boss_id == MyId || i.cuser_id == MyId).OrderBy(i => i.userName).ToList(); } ; return(View(model)); }
/// <summary> /// 得到 /// </summary> /// <returns></returns> protected virtual IList <StaffEntity> GetStaffs(StaffListModel model) { var query = new QueryInfo(); query.SetPageSize(model.PageSize).SetPageIndex(model.PageIndex) .Query <StaffEntity>().Select(it => new object[] { it.Id, it.Name, it.Account.Id }); return(this.GetEntities <StaffEntity>(query)); }
public virtual ActionResult List(int?page) { var model = new StaffListModel { PageIndex = page.HasValue ? page.Value : 0 }; model.Staffs = GetStaffs(model); return(View("~/Views/Staff/_Staff.cshtml", model)); }
public ActionResult <StaffListModel> GetAllStaffList(PageResult pageResult) { StaffListModel staffList = new StaffListModel(); try { staffList = _staffService.GetAllStaffList(pageResult); } catch (Exception es) { staffList._message = es.Message; staffList._failure = true; } return(staffList); }
/// <summary> /// 得到 /// </summary> /// <returns></returns> protected virtual IList <StaffEntity> GetStaffs(StaffListModel model) { if (Staff == null || Staff.ReadCustomerType == ReadCustomerType.Self) { return(null); } var query = new QueryInfo(); query.SetPageSize(model.PageSize).SetPageIndex(model.PageIndex).Query <StaffEntity>() .Where(it => it.Crm.Id == CrmId).Select(it => new object[] { it.Id, it.Name }); if (Staff.ReadCustomerType == ReadCustomerType.Department) { query.SetParameter("DepartmentId", Staff.Department == null ? 0 : Staff.Department.Id) .Where(string.Format("{0} && Department.Id==@DepartmentId", query.WhereExp)); } return(this.GetEntities <StaffEntity>(query)); }
/// <summary> /// Get All Staff List /// </summary> /// <param name="pageResult"></param> /// <returns></returns> public StaffListModel GetAllStaffList(PageResult pageResult) { logger.Info("Method getAllStaffList called."); StaffListModel staffList = new StaffListModel(); try { if (TokenManager.CheckToken(pageResult._tenantName + pageResult._userName, pageResult._token)) { staffList = this.staffRepository.GetAllStaffList(pageResult); if (staffList.staffMaster.Count > 0) { staffList._message = SUCCESS; staffList._failure = false; } else { staffList._message = "NO RECORD FOUND"; staffList._failure = true; } logger.Info("Method getAllStaffList end with success."); } else { staffList._failure = true; staffList._message = TOKENINVALID; return(staffList); } } catch (Exception ex) { staffList._message = ex.Message; staffList._failure = true; logger.Error("Method getAllStaffList end with error :" + ex.Message); } return(staffList); }
public StaffListModel GetStaffInfosBySalon(string salonCode) { StaffListModel staffList = new StaffListModel(); staffList.Dates = GetDates(); staffList.StaffInfos = new List <StaffInfoModel>(); using (var context = new ApplicationDbContext()) { var listStaff = context.Staffs.Where(w => w.SalonCode == salonCode).OrderBy(m => m.Code); foreach (var item in listStaff) { StaffInfoModel model = new StaffInfoModel(); ModelHelper.CopyModel(model, item); model.ServiceTimes = new Dictionary <string, List <StaffServiceTimeModel> >(); List <StaffServiceTimeModel> servicestime = new List <StaffServiceTimeModel>(); if (!string.IsNullOrEmpty(item.ServiceTimes)) { servicestime = JsonConvert.DeserializeObject <List <StaffServiceTimeModel> >(item.ServiceTimes); } if (servicestime.Count > 0) { foreach (var date in staffList.Dates) { var booktimes = context.StaffBookTimes.Where(m => m.StaffCode == model.Code && m.Date == date).ToList(); var times = servicestime.Where(m => !booktimes.Any(m2 => m2.ServiceTimeCode == m.Code)).ToList(); times.ForEach(m => m.AreaTime = m.StartTime + '-' + m.EndTime); model.ServiceTimes.Add(date, times); } } staffList.StaffInfos.Add(model); } } return(staffList); }