Example #1
0
 public ActionResult Edit(BusinessObjects.Models.Counter counter)
 {
     try
     {
         if (ModelState.IsValid)
         {
             BusinessAccessLayer.BALCommon.BALCommon   bALCommon    = new BusinessAccessLayer.BALCommon.BALCommon();
             BusinessAccessLayer.BALCounter.BALCounter bALCounter   = new BusinessAccessLayer.BALCounter.BALCounter();
             BusinessObjects.Models.ResultsEnum        checkUpdated = bALCounter.updateCounter(counter, ((BusinessObjects.Models.User)Session["UserObj"]).bankId);
             if (checkUpdated == BusinessObjects.Models.ResultsEnum.notUpdated)
             {
                 TempData["errorMsg"] = LangText.checkConnection;
                 return(RedirectToAction("Home", "Counters", new { branchId = counter.branchId }));
             }
             else if (checkUpdated == BusinessObjects.Models.ResultsEnum.updated)
             {
                 return(RedirectToAction("Home", "Counters", new { branchId = counter.branchId }));
             }
             else
             {
                 TempData["errorMsg"] = LangText.somethingWentWrongAlert;
                 return(RedirectToAction("Home", "Counters", new { branchId = counter.branchId }));
             }
         }
         else
         {
             return(View());
         }
     }
     catch (Exception ex)
     {
         ExceptionsWriter.saveExceptionToLogFile(ex);
         return(View("Error"));
     }
 }
        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);
     }
 }
Example #4
0
        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);
        }
Example #5
0
 /// <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);
     }
 }
 /// <summary>
 /// Get counters for selected branch from database and return counterHome view
 /// </summary>
 public ActionResult Home(int branchId)
 {
     try
     {
         if (TempData["errorMsg"] != null)
         {
             ViewBag.errorMsg     = TempData["errorMsg"];
             TempData["errorMsg"] = null;
         }
         ViewBag.branchId = branchId;
         BusinessAccessLayer.BALCommon.BALCommon   bALCommon  = new BusinessAccessLayer.BALCommon.BALCommon();
         BusinessAccessLayer.BALCounter.BALCounter bALCounter = new BusinessAccessLayer.BALCounter.BALCounter();
         ClaimsPrincipal principal = HttpContext.User as ClaimsPrincipal;
         var             bankId    = Convert.ToInt32(principal.FindFirst("BankId").Value);
         List <BusinessObjects.Models.Counter> lstCounters = bALCounter.selectCountersByBranchId(branchId, bankId);
         if (lstCounters == null)
         {
             TempData["errorMsg"] = LangText.checkConnection;
             return(RedirectToAction("Home", "Branches"));
         }
         else if (lstCounters.Count == 0)
         {
             return(View());
         }
         else if (lstCounters.FirstOrDefault().id == 0)
         {
             TempData["errorMsg"] = LangText.somethingWentWrongAlert;
             return(RedirectToAction("Home", "Branches"));
         }
         else
         {
             return(View(lstCounters));
         }
     }
     catch (Exception ex)
     {
         ExceptionsWriter.saveEventsAndExceptions(ex, "Exceptions not handled", EventLogEntryType.Error);
         return(View("Error"));
     }
 }
Example #7
0
 /// <summary>
 /// Get counters for selected branch from database and return counterHome view
 /// </summary>
 public ActionResult Home(int branchId)
 {
     try
     {
         if (TempData["errorMsg"] != null)
         {
             ViewBag.errorMsg     = TempData["errorMsg"];
             TempData["errorMsg"] = null;
         }
         ViewBag.branchId = branchId;
         BusinessAccessLayer.BALCommon.BALCommon   bALCommon   = new BusinessAccessLayer.BALCommon.BALCommon();
         BusinessAccessLayer.BALCounter.BALCounter bALCounter  = new BusinessAccessLayer.BALCounter.BALCounter();
         List <BusinessObjects.Models.Counter>     lstCounters = bALCounter.selectCountersByBranchId(branchId, ((BusinessObjects.Models.User)Session["UserObj"]).bankId);
         if (lstCounters == null)
         {
             TempData["errorMsg"] = LangText.checkConnection;
             return(RedirectToAction("Home", "Branches"));
         }
         else if (lstCounters.Count == 0)
         {
             return(View());
         }
         else if (lstCounters.FirstOrDefault().id == 0)
         {
             TempData["errorMsg"] = LangText.somethingWentWrongAlert;
             return(RedirectToAction("Home", "Branches"));
         }
         else
         {
             return(View(lstCounters));
         }
     }
     catch (Exception ex)
     {
         ExceptionsWriter.saveExceptionToLogFile(ex);
         return(View("Error"));
     }
 }
Example #8
0
 public ActionResult Edit(BusinessObjects.Models.Service service)
 {
     try
     {
         if (ModelState.IsValid)
         {
             ClaimsPrincipal principal = HttpContext.User as ClaimsPrincipal;
             var             bankId    = Convert.ToInt32(principal.FindFirst("BankId").Value);
             service.bankId = bankId;
             BusinessAccessLayer.BALCommon.BALCommon   bALCommon    = new BusinessAccessLayer.BALCommon.BALCommon();
             BusinessAccessLayer.BALService.BALService bALServices  = new BusinessAccessLayer.BALService.BALService();
             BusinessObjects.Models.ResultsEnum        checkUpdated = bALServices.updateService(service);
             if (checkUpdated == BusinessObjects.Models.ResultsEnum.notUpdated)
             {
                 TempData["errorMsg"] = LangText.checkConnection;
                 return(RedirectToAction("Home", "Services"));
             }
             else if (checkUpdated == BusinessObjects.Models.ResultsEnum.updated)
             {
                 return(RedirectToAction("Home", "Services"));
             }
             else
             {
                 TempData["errorMsg"] = LangText.somethingWentWrongAlert;
                 return(RedirectToAction("Home", "Services"));
             }
         }
         else
         {
             return(View());
         }
     }
     catch (Exception ex)
     {
         ExceptionsWriter.saveEventsAndExceptions(ex, "Exceptions not handled", EventLogEntryType.Error);
         return(View("Error"));
     }
 }
 public ActionResult Edit(BusinessObjects.Models.Service service)
 {
     try
     {
         if (ModelState.IsValid)
         {
             service.bankId = ((BusinessObjects.Models.User)Session["UserObj"]).bankId;
             BusinessAccessLayer.BALCommon.BALCommon   bALCommon    = new BusinessAccessLayer.BALCommon.BALCommon();
             BusinessAccessLayer.BALService.BALService bALServices  = new BusinessAccessLayer.BALService.BALService();
             BusinessObjects.Models.ResultsEnum        checkUpdated = bALServices.updateService(service);
             if (checkUpdated == BusinessObjects.Models.ResultsEnum.notUpdated)
             {
                 TempData["errorMsg"] = LangText.checkConnection;
                 return(RedirectToAction("Home", "Services"));
             }
             else if (checkUpdated == BusinessObjects.Models.ResultsEnum.updated)
             {
                 return(RedirectToAction("Home", "Services"));
             }
             else
             {
                 TempData["errorMsg"] = LangText.somethingWentWrongAlert;
                 return(RedirectToAction("Home", "Services"));
             }
         }
         else
         {
             return(View());
         }
     }
     catch (Exception ex)
     {
         ExceptionsWriter.saveExceptionToLogFile(ex);
         return(View("Error"));
     }
 }