private CustomerServiceModel GetServices(int currentPage) { int maxRows = 8; BusinessAccessLayer.BALCommon.BALCommon bALCommon = new BusinessAccessLayer.BALCommon.BALCommon(); BusinessAccessLayer.BALService.BALService bALService = new BusinessAccessLayer.BALService.BALService(); List <BusinessObjects.Models.Service> lstServices = bALService.selectServicesByBankId(((BusinessObjects.Models.User)Session["UserObj"]).bankId); CustomerServiceModel servicesModel = new CustomerServiceModel(); servicesModel.Services = lstServices.ToList().Skip((currentPage - 1) * maxRows).Take(maxRows).ToList(); double pageCount = (double)((decimal)lstServices.Count() / Convert.ToDecimal(maxRows)); servicesModel.PageCount = (int)Math.Ceiling(pageCount); servicesModel.CurrentPageIndex = currentPage; return(servicesModel); }
/// <summary> /// Get counters for services that are not allocated to current selected counter /// </summary> public BusinessObjects.Models.ResultsEnum FillAllocateBag(int counterId) { try { ViewBag.counterId = counterId; BusinessAccessLayer.BALCommon.BALCommon bALCommon = new BusinessAccessLayer.BALCommon.BALCommon(); BusinessAccessLayer.BALAllocateCounterService.BALAllocateCounterService bALAllocateCounterService = new BusinessAccessLayer.BALAllocateCounterService.BALAllocateCounterService(); BusinessAccessLayer.BALService.BALService bALService = new BusinessAccessLayer.BALService.BALService(); List <Models.ServiceAllocate> lstServiceAllocate = new List <ServiceAllocate>(); ClaimsPrincipal principal = HttpContext.User as ClaimsPrincipal; var bankId = Convert.ToInt32(principal.FindFirst("BankId").Value); List <BusinessObjects.Models.Service> lstServices = bALService.selectServicesByBankId(bankId); List <BusinessObjects.Models.AllocateCounterService> lstAllocateCounterService = bALAllocateCounterService.selectAllocateCounterService(counterId, bankId); if (lstAllocateCounterService == null) { ViewBag.AllocateId = new SelectList(lstServiceAllocate, "id", System.Globalization.CultureInfo.CurrentCulture.ToString() == "en" ? "enName" : "arName"); return(BusinessObjects.Models.ResultsEnum.error); } else if (lstAllocateCounterService.Count == 0 || lstAllocateCounterService.FirstOrDefault().id > 0) { foreach (var item in lstServices) { if (lstAllocateCounterService.Where(x => x.serviceId == item.id).FirstOrDefault() != null) { item.isDeleted = true; } else { lstServiceAllocate.Add(new ServiceAllocate(item.id, item.enName, item.arName, counterId, null)); } } ViewBag.AllocateId = new SelectList(lstServiceAllocate, "id", System.Globalization.CultureInfo.CurrentCulture.ToString() == "en" ? "enName" : "arName"); return(BusinessObjects.Models.ResultsEnum.filled); } else { ViewBag.AllocateId = new SelectList(lstServiceAllocate, "id", System.Globalization.CultureInfo.CurrentCulture.ToString() == "en" ? "enName" : "arName"); return(BusinessObjects.Models.ResultsEnum.notFound); } } catch (Exception ex) { ExceptionsWriter.saveEventsAndExceptions(ex, "Exceptions not handled", EventLogEntryType.Error); return(BusinessObjects.Models.ResultsEnum.error); } }
private CustomerServiceModel GetServices(int currentPage) { int maxRows = 7; BusinessAccessLayer.BALCommon.BALCommon bALCommon = new BusinessAccessLayer.BALCommon.BALCommon(); BusinessAccessLayer.BALService.BALService bALService = new BusinessAccessLayer.BALService.BALService(); ClaimsPrincipal principal = HttpContext.User as ClaimsPrincipal; var bankId = Convert.ToInt32(principal.FindFirst("BankId").Value); List <BusinessObjects.Models.Service> lstServices = bALService.selectServicesByBankId(bankId); CustomerServiceModel servicesModel = new CustomerServiceModel(); servicesModel.Services = lstServices.ToList().Skip((currentPage - 1) * maxRows).Take(maxRows).ToList(); double pageCount = (double)((decimal)lstServices.Count() / Convert.ToDecimal(maxRows)); servicesModel.PageCount = (int)Math.Ceiling(pageCount); servicesModel.CurrentPageIndex = currentPage; return(servicesModel); }
/// <summary> /// Get counters for services that are not allocated to current selected counter /// </summary> public BusinessObjects.Models.ResultsEnum FillAllocateBag(int counterId) { try { ViewBag.counterId = counterId; BusinessAccessLayer.BALCommon.BALCommon bALCommon = new BusinessAccessLayer.BALCommon.BALCommon(); BusinessAccessLayer.BALAllocateCounterService.BALAllocateCounterService bALAllocateCounterService = new BusinessAccessLayer.BALAllocateCounterService.BALAllocateCounterService(); BusinessAccessLayer.BALService.BALService bALService = new BusinessAccessLayer.BALService.BALService(); List <Models.ServiceAllocate> lstServiceAllocate = new List <ServiceAllocate>(); List <BusinessObjects.Models.Service> lstServices = bALService.selectServicesByBankId(((BusinessObjects.Models.User)Session["UserObj"]).bankId); List <BusinessObjects.Models.AllocateCounterService> lstAllocateCounterService = bALAllocateCounterService.selectAllocateCounterService(counterId, ((BusinessObjects.Models.User)Session["UserObj"]).bankId); if (lstAllocateCounterService == null) { ViewBag.AllocateId = new SelectList(lstServiceAllocate, "id", System.Globalization.CultureInfo.CurrentCulture.ToString() == "en" ? "enName" : "arName"); return(BusinessObjects.Models.ResultsEnum.error); } else if (lstAllocateCounterService.Count == 0 || lstAllocateCounterService.FirstOrDefault().id > 0) { foreach (var item in lstServices) { if (lstAllocateCounterService.Where(x => x.serviceId == item.id).FirstOrDefault() != null) { item.isDeleted = true; } else { lstServiceAllocate.Add(new ServiceAllocate(item.id, item.enName, item.arName, counterId, null)); } } ViewBag.AllocateId = new SelectList(lstServiceAllocate, "id", System.Globalization.CultureInfo.CurrentCulture.ToString() == "en" ? "enName" : "arName"); return(BusinessObjects.Models.ResultsEnum.filled); } else { ViewBag.AllocateId = new SelectList(lstServiceAllocate, "id", System.Globalization.CultureInfo.CurrentCulture.ToString() == "en" ? "enName" : "arName"); return(BusinessObjects.Models.ResultsEnum.deleted); } } catch (Exception ex) { ExceptionsWriter.saveExceptionToLogFile(ex); return(BusinessObjects.Models.ResultsEnum.error); } }