public HttpResponseMessage GetAll(HttpRequestMessage request, int page, int pageSize = 100) { return(CreateHttpResponse(request, () => { int totalRow = 0; var model = _propertyServiceSerivce.GetAll(); totalRow = model.Count(); var query = model.OrderBy(x => x.ID).Skip(page * pageSize).Take(pageSize); var responseData = Mapper.Map <IEnumerable <PropertyService>, IEnumerable <PropertyServiceViewModel> >(query); foreach (var item in responseData) { item.ServiceName = _serviceService.GetById(item.ServiceID).Name; } var paginationSet = new PaginationSet <PropertyServiceViewModel>//sai ne ban. { Items = responseData, Page = page, TotalCount = totalRow, TotalPages = (int)Math.Ceiling((decimal)totalRow / pageSize) }; var response = request.CreateResponse(HttpStatusCode.OK, paginationSet); return response; })); }
public ActionResult Edit(int id) { var entity = _serviceService.GetById(id); var viewModel = Mapper.Map <Service, ServiceViewModel>(entity); viewModel.ServiceSubcategoriesSelectList = Mapper.Map <List <ServiceSubcategory>, List <SelectListItem> >(_subcategoryService.GetAll()); AddLocales(viewModel.Locales, (locale, languageId) => { locale.Title = entity.GetLocalized(x => x.Title, languageId); locale.SubTitle = entity.GetLocalized(x => x.SubTitle, languageId); locale.Description = entity.GetLocalized(x => x.Description, languageId); locale.Content = entity.GetLocalized(x => x.Content, languageId); }); return(View(viewModel)); }
public virtual IActionResult Edit(int id) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageServices)) { return(AccessDeniedView()); } var e = _serviceService.GetById(id); if (e == null || e.Deleted) { return(RedirectToAction("List")); } //prepare model var model = PrepareModel(null, e); return(View(model)); }
public IActionResult EditService(int Id) { var service = serviceService.GetById(Id); if (service == null) { return(RedirectToAction(nameof(ServiceManageController.Index), "ServiceManage")); } return(View(new ServiceViewModel().InjectFrom(service) as ServiceViewModel)); }
public async Task <IActionResult> SelectServices(BookingModel model, int[] serviceIds) { if (model.EmployeeId == null || string.IsNullOrEmpty(model.SelectedDay) || string.IsNullOrEmpty(model.SelectedTime)) { TempData.Put("message", new AlertType() { Title = "Hata", Message = "Kuaför ve rezervasyon zamanı boş olamaz!", Alert = "warning" } ); return(View(model)); } if (serviceIds.Length == 0) { TempData.Put("message", new AlertType() { Title = "Hata", Message = "İşlem seçmelisiniz!", Alert = "warning" } ); return(View(model)); } var selectedDay = Convert.ToDateTime(model.SelectedDay); var selectedTime = DateTime.ParseExact(model.SelectedTime, "HH:mm", CultureInfo.InvariantCulture); var barber = await _userManager.FindByIdAsync(model.EmployeeId); var serviceNames = new List <string>(); var servicePrices = new List <double>(); foreach (var id in serviceIds) { var service = _serviceService.GetById(id); serviceNames.Add(service.name); servicePrices.Add(service.price); } var bookingInfoModel = new BookingInfoModel() { CustomerId = model.CustomerId, EmployeeId = model.EmployeeId, date = selectedDay.AddHours(selectedTime.Hour).AddMinutes(selectedTime.Minute), ServiceIds = serviceIds, barberName = barber.FirstName + " " + barber.LastName, barberImageUrl = barber.ImageUrl, serviceNames = serviceNames, servicePrices = servicePrices }; return(View("CreateBooking", bookingInfoModel)); }
public async Task <ActionResult <ServiceDTO> > GetById(int id) { var result = await _serviceService.GetById(id); if (!result.Success) { return(NotFound(result.Messages)); } return(result.service); }
public HttpResponseMessage Update(HttpRequestMessage request, ServiceViewModel serviceVm) { return(CreateHttpResponse(request, () => { HttpResponseMessage response = null; if (!ModelState.IsValid) { response = request.CreateResponse(HttpStatusCode.BadRequest, ModelState); } else { var dbService = _serviceService.GetById(serviceVm.ID); serviceVm.UpdatedBy = User.Identity.Name; dbService.UpdateService(serviceVm); _serviceService.Update(dbService); _serviceService.Save(); var responseData = Mapper.Map <PostOffice.Model.Models.Service, ServiceViewModel>(dbService); response = request.CreateResponse(HttpStatusCode.Created, responseData); } return response; })); }
public IActionResult Details(Guid serviceId) { var service = _serviceService.GetById(serviceId); return(View(service)); }
public Model.Service GetById(int id) { return(_service.GetById(id)); }
public async Task <ServiceResponse> GetByID(string id) { return(await _serviceService.GetById(id)); }
public async Task <HttpResponseMessage> RP1(HttpRequestMessage request, string fromDate, string toDate, int districtId, int functionId, int poId, string userSelected, int serviceId) { //check role bool isAdmin = false; bool isManager = false; isAdmin = _userService.CheckRole(User.Identity.Name, "Administrator"); isManager = _userService.CheckRole(User.Identity.Name, "Manager"); bool isSupport = _userService.CheckRole(User.Identity.Name, "Support"); #region Config Export file string fileName = string.Concat("Money_" + DateTime.Now.ToString("yyyyMMddhhmmsss") + ".xlsx"); var folderReport = ConfigHelper.GetByKey("ReportFolder"); string filePath = HttpContext.Current.Server.MapPath(folderReport); if (!Directory.Exists(filePath)) { Directory.CreateDirectory(filePath); } string fullPath = Path.Combine(filePath, fileName); #endregion Config Export file ReportTemplate vm = new ReportTemplate(); //IEnumerable<RP1Advance> rp1Advance; try { #region customFill Test District district = new District(); PO po = new PO(); ApplicationUser user = new ApplicationUser(); Model.Models.Service sv = new Model.Models.Service(); // current user string currentUser = User.Identity.Name; // Thời gian để xuất dữ liệu DateTime fd; DateTime td; try { fd = DateTime.ParseExact(fromDate, "MM/dd/yyyy", CultureInfo.InvariantCulture); vm.FromDate = fd; td = DateTime.ParseExact(toDate, "MM/dd/yyyy", CultureInfo.InvariantCulture); vm.ToDate = td; } catch (Exception) { throw; } vm.CreatedBy = currentUser; //check param đầu vào #region data input if (districtId != 0) { district = _districtService.GetById(districtId); vm.District = district.Name; } if (poId != 0) { po = _poService.GetByID(poId); vm.Unit = po.Name; } if (!string.IsNullOrEmpty(userSelected)) { user = _userService.getByUserId(userSelected); vm.user = user.FullName; } if (serviceId != 0) { sv = _serviceService.GetById(serviceId); vm.Service = sv.Name; } #endregion data input switch (functionId) { #region case 1 Bảng kê thu tiền tại bưu cục - tổng hợp case 1: vm.FunctionName = "Bảng kê thu tiền tại bưu cục - tổng hợp"; // BCCP var query = _statisticService.Export_By_Service_Group_And_Time_District_Po_BCCP(fromDate, toDate, districtId, poId, currentUser, userSelected); var c = query.Count(); var responseBCCP = Mapper.Map <IEnumerable <Export_By_Service_Group_And_Time_District_Po_BCCP>, IEnumerable <Export_By_Service_Group_And_Time_District_Po_BCCP_VM> >(query); foreach (var item in responseBCCP) { item.TotalMoneyBeforeVat = (item.TotalCash + item.TotalDebt) / (decimal)item.VAT; item.TotalVat = (item.TotalCash + item.TotalDebt) - ((item.TotalCash + item.TotalDebt) / (decimal)item.VAT); } var responseBCCP1 = Mapper.Map <IEnumerable <Export_By_Service_Group_And_Time_District_Po_BCCP_VM>, IEnumerable <Export_Template_VM> >(responseBCCP); //TCBC var query2 = _statisticService.Get_General_TCBC(fromDate, toDate, districtId, poId, currentUser, userSelected); var c2 = query2.Count(); var responseTCBC = Mapper.Map <IEnumerable <Get_General_TCBC>, IEnumerable <Get_General_TCBC_VM> >(query2); foreach (var item in responseTCBC) { item.Tax = item.Sales - item.Sales / (decimal)item.VAT; } var responseTCBC1 = Mapper.Map <IEnumerable <Get_General_TCBC_VM>, IEnumerable <Export_Template_TCBC> >(responseTCBC); //PPTT var query3 = _statisticService.Export_By_Service_Group_And_Time_District_Po_PPTT(fromDate, toDate, districtId, poId, currentUser, userSelected); var responsePPTT = Mapper.Map <IEnumerable <Export_By_Service_Group_And_Time_District_Po_BCCP>, IEnumerable <Export_By_Service_Group_And_Time_District_Po_BCCP_VM> >(query3); foreach (var item in responsePPTT) { item.TotalMoneyBeforeVat = (item.TotalCash + item.TotalDebt) / (decimal)item.VAT; item.TotalVat = (item.TotalCash + item.TotalDebt) - ((item.TotalCash + item.TotalDebt) / (decimal)item.VAT); } var responsePPTT1 = Mapper.Map <IEnumerable <Export_By_Service_Group_And_Time_District_Po_BCCP_VM>, IEnumerable <Export_Template_VM> >(responsePPTT); await ReportHelper.Export_By_Service_Group_And_Time(responseBCCP1.ToList(), responsePPTT1.ToList(), responseTCBC1.ToList(), fullPath, vm); break; #endregion case 1 Bảng kê thu tiền tại bưu cục - tổng hợp #region case 2 Bảng kê thu tiền tại bưu cục - chi tiết case 2: vm.FunctionName = "Bảng kê thu tiền tại bưu cục - chi tiết"; // check if basic user //if (!isAdmin && !isManager && !isSupport) //{ // break; //} #region BCCP var q1 = _trasactionService.GetByCondition_BCCP(fd, td, districtId, poId, currentUser); var c4 = q1.Count(); var BCCP = Mapper.Map <IEnumerable <Transaction>, IEnumerable <TransactionViewModel> >(q1); #region foreach foreach (var item in BCCP) { item.VAT = _serviceService.GetById(item.ServiceId).VAT; item.Quantity = Convert.ToInt32(_transactionDetailService.GetAllByCondition("Sản lượng", item.ID).Money); item.ServiceName = _serviceService.GetById(item.ServiceId).Name; if (!item.IsCash) { item.TotalDebt = _transactionDetailService.GetTotalMoneyByTransactionId(item.ID); item.TotalCash = 0; } else { item.TotalCash = _transactionDetailService.GetTotalMoneyByTransactionId(item.ID); item.TotalDebt = 0; } item.EarnMoney = _transactionDetailService.GetTotalEarnMoneyByTransactionId(item.ID); item.TotalMoneyBeforeVat = (item.TotalCash + item.TotalDebt) / (decimal)item.VAT; item.TotalVat = (item.TotalCash + item.TotalDebt) - ((item.TotalCash + item.TotalDebt) / (decimal)item.VAT); } #endregion var resBCCP = Mapper.Map <IEnumerable <TransactionViewModel>, IEnumerable <Export_Template_VM> >(BCCP); foreach (var item in resBCCP) { var stt = item.STT; var name = item.ServiceName; var qty = item.Quantity; var cash = item.TotalCash; var debt = item.TotalDebt; var m1 = item.TotalMoneyBeforeVat; var vat = item.TotalVat; var e = item.EarnMoney; } #endregion #region TCBC var q2 = _trasactionService.GetByCondition_TCBC(fd, td, districtId, poId, currentUser); var c5 = q2.Count(); var TCBC = Mapper.Map <IEnumerable <Transaction>, IEnumerable <TransactionViewModel> >(q2); #region foreach foreach (var item in TCBC) { item.VAT = _serviceService.GetById(item.ServiceId).VAT; item.Quantity = Convert.ToInt32(_transactionDetailService.GetAllByCondition("Sản lượng", item.ID).Money); var Fe = _transactionDetailService.GetFeeById("Số tiền cước", item.ID); if (Fe == null) { item.Fee = 0; } else { item.Fee = Fe.Money; } item.ServiceName = _serviceService.GetById(item.ServiceId).Name; item.EarnMoney = _transactionDetailService.GetTotalEarnMoneyByTransactionId(item.ID); var groupId = _serviceGroupService.GetSigleByServiceId(item.ID); if (groupId != null && (groupId.ID == 93 || groupId.ID == 75)) { item.IsReceive = true; item.TotalColection = _transactionDetailService.GetTotalMoneyByTransactionId(item.ID); item.TotalPay = 0; } else { item.IsReceive = false; item.TotalPay = _transactionDetailService.GetTotalMoneyByTransactionId(item.ID); item.TotalColection = 0; } } #endregion var resTCBC_temp = Mapper.Map <IEnumerable <TransactionViewModel>, IEnumerable <Get_General_TCBC> >(TCBC); var resTCBC_temp2 = Mapper.Map <IEnumerable <Get_General_TCBC>, IEnumerable <Get_General_TCBC_VM> >(resTCBC_temp); foreach (var item in resTCBC_temp2) { item.Sales = item.EarnMoney * (decimal)item.VAT; item.Tax = item.Sales - item.Sales / (decimal)item.VAT; var name = item.ServiceName; var qty = item.Quantity; var co = item.TotalColection; var p = item.TotalPay; var m1 = item.Sales; var f = item.Fee; var e = item.EarnMoney; } var resTCBC = Mapper.Map <IEnumerable <Get_General_TCBC_VM>, IEnumerable <Export_Template_TCBC> >(resTCBC_temp2); #endregion #region PPTT var q3 = _trasactionService.GetByCondition_PPTT(fd, td, districtId, poId, currentUser); var c6 = q3.Count(); var PPTT = Mapper.Map <IEnumerable <Transaction>, IEnumerable <TransactionViewModel> >(q3); foreach (var item in PPTT) { item.VAT = _serviceService.GetById(item.ServiceId).VAT; item.Quantity = Convert.ToInt32(_transactionDetailService.GetAllByCondition("Sản lượng", item.ID).Money); item.ServiceName = _serviceService.GetById(item.ServiceId).Name; if (!item.IsCash) { item.TotalDebt = _transactionDetailService.GetTotalMoneyByTransactionId(item.ID); item.TotalCash = 0; } else { item.TotalCash = _transactionDetailService.GetTotalMoneyByTransactionId(item.ID); item.TotalDebt = 0; } item.EarnMoney = _transactionDetailService.GetTotalEarnMoneyByTransactionId(item.ID); item.TotalMoneyBeforeVat = (item.TotalCash + item.TotalDebt) / (decimal)item.VAT; item.TotalVat = (item.TotalCash + item.TotalDebt) - ((item.TotalCash + item.TotalDebt) / (decimal)item.VAT); } var resPPTT = Mapper.Map <IEnumerable <TransactionViewModel>, IEnumerable <Export_Template_VM> >(PPTT); #endregion await ReportHelper.RP2_1(resBCCP.ToList(), resPPTT.ToList(), resTCBC.ToList(), fullPath, vm); break; #endregion customFill Test #region case 3 Bảng kê thu tiền theo nhân viên case 3: vm.FunctionName = "Bảng kê thu tiền theo nhân viên"; // =============== BCCP =================== var c3_bccp = _statisticService.Export_By_Service_Group_And_Time_District_Po_BCCP(fromDate, toDate, districtId, poId, currentUser, userSelected); int test = c3_bccp.Count(); var responseBCCP3 = Mapper.Map <IEnumerable <Export_By_Service_Group_And_Time_District_Po_BCCP>, IEnumerable <Export_By_Service_Group_And_Time_District_Po_BCCP_VM> >(c3_bccp); foreach (var item in responseBCCP3) { item.TotalMoneyBeforeVat = (item.TotalCash + item.TotalDebt) / (decimal)item.VAT; item.TotalVat = (item.TotalCash + item.TotalDebt) - ((item.TotalCash + item.TotalDebt) / (decimal)item.VAT); } var c3_bccp_final = Mapper.Map <IEnumerable <Export_By_Service_Group_And_Time_District_Po_BCCP_VM>, IEnumerable <Export_Template_VM> >(responseBCCP3); //foreach (var item in responseBCCP3) //{ // item.TotalMoneyBeforeVat = (item.TotalCash + item.TotalDebt) / (decimal)item.VAT; //} // =============== PPTT =================== var c3_pptt = _statisticService.Export_By_Service_Group_And_Time_District_Po_PPTT(fromDate, toDate, districtId, poId, currentUser, userSelected); test = c3_pptt.Count(); var responsePPTT3 = Mapper.Map <IEnumerable <Export_By_Service_Group_And_Time_District_Po_BCCP>, IEnumerable <Export_By_Service_Group_And_Time_District_Po_BCCP_VM> >(c3_pptt); foreach (var item in responsePPTT3) { item.TotalMoneyBeforeVat = (item.TotalCash + item.TotalDebt) / (decimal)item.VAT; item.TotalVat = (item.TotalCash + item.TotalDebt) - ((item.TotalCash + item.TotalDebt) / (decimal)item.VAT); } var c3_pptt_final = Mapper.Map <IEnumerable <Export_By_Service_Group_And_Time_District_Po_BCCP_VM>, IEnumerable <Export_Template_VM> >(responsePPTT3); //foreach (var item in responsePPTT3) //{ // item.TotalMoneyBeforeVat = (item.TotalCash + item.TotalDebt) / (decimal)item.VAT; //} // =============== TCBC =================== var c3_tcbc = _statisticService.Get_General_TCBC(fromDate, toDate, districtId, poId, currentUser, userSelected); test = c3_tcbc.Count(); var responseTCBC3 = Mapper.Map <IEnumerable <Get_General_TCBC>, IEnumerable <Get_General_TCBC_VM> >(c3_tcbc); foreach (var item in responseTCBC3) { item.Tax = item.Sales - item.Sales / (decimal)item.VAT; } var c3_tcbc_final = Mapper.Map <IEnumerable <Get_General_TCBC_VM>, IEnumerable <Export_Template_TCBC> >(responseTCBC3); //var c3_tcbc = _statisticService.Export_By_Service_Group_TCBC(fromDate, toDate, districtId, poId, currentUser, userSelected); //test = c3_tcbc.Count(); //var responseTCBC3 = Mapper.Map<IEnumerable<Export_By_Service_Group_TCBC>, IEnumerable<Export_By_Service_Group_TCBC_Vm>>(c3_tcbc); //foreach (var item in responseTCBC3) //{ // item.TotalMoney = (item.TotalColection + item.TotalPay) / (decimal)item.VAT; //} //var responseOther3 = _statisticService.Export_By_Service_Group_And_Time(fromDate, toDate, otherId, districtId, poId, userId); await ReportHelper.RP2_1(c3_bccp_final.ToList(), c3_pptt_final.ToList(), c3_tcbc_final.ToList(), fullPath, vm); break; #endregion case 3 Bảng kê thu tiền theo nhân viên #region feature function case 4: vm.FunctionName = "Bảng kê thu tiền theo dịch vụ"; break; case 5: vm.FunctionName = "Bảng kê thu tiền theo nhân viên và dịch vụ"; break; default: vm.FunctionName = "Chức năng khác"; break; #endregion feature function } #endregion case 3 Bảng kê thu tiền theo nhân viên return(request.CreateErrorResponse(HttpStatusCode.OK, Path.Combine(folderReport, fileName))); } catch (Exception ex) { return(request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message)); } }
public HttpResponseMessage GetAllByTime(HttpRequestMessage request, DateTime fromDate, DateTime toDate, int districtId, int posId, string userId, int serviceId) { return(CreateHttpResponse(request, () => { try { var model = _transactionService.General_statistic(fromDate, toDate, districtId, posId, User.Identity.Name, userId, serviceId); var responseData = Mapper.Map <IEnumerable <Transaction>, IEnumerable <TransactionViewModel> >(model); foreach (var item in responseData) { item.groupId = _serviceGr.GetGroupIdByServiceId(item.ServiceId); item.VAT = _serviceService.GetById(item.ServiceId).VAT; item.Quantity = Convert.ToInt32(_transactionDetailService.GetAllByCondition("Sản lượng", item.ID).Money); item.ServiceName = _serviceService.GetById(item.ServiceId).Name; if (!item.IsCash && item.groupId != 94) { item.TotalDebt = _transactionDetailService.GetTotalMoneyByTransactionId(item.ID); } else { if (item.groupId == 94) { if (item.IsCurrency && item.ServiceId == 1769) { item.TotalCurrency = _transactionDetailService.GetTotalMoneyByTransactionId(item.ID); } else { item.TotalMoneySent = _transactionDetailService.GetTotalMoneyByTransactionId(item.ID); } } else { item.TotalCash = _transactionDetailService.GetTotalMoneyByTransactionId(item.ID); } } item.EarnMoney = _transactionDetailService.GetTotalEarnMoneyByTransactionId(item.ID); } var response = request.CreateResponse(HttpStatusCode.OK, responseData); return response; } catch (Exception e) { return request.CreateResponse(HttpStatusCode.ExpectationFailed, e.Message); } })); }