public async Task <IActionResult> GetAll([FromQuery] PageParams pageParams, [FromBody] BillDetailModel getBillDetailModel) { ServiceResponseModel <IEnumerable <BillDetail> > response = new ServiceResponseModel <IEnumerable <BillDetail> >(); try { if (string.IsNullOrWhiteSpace(getBillDetailModel.CompCode)) { throw new ArgumentNullException("CompCode is required"); } if (string.IsNullOrWhiteSpace(getBillDetailModel.AccYear)) { throw new ArgumentNullException("AccYear is required"); } var billDetailList = await _billDetailService.GetAll(pageParams, getBillDetailModel); Response.AddPaginationHeader(billDetailList.CurrentPage, billDetailList.PageSize, billDetailList.TotalCount, billDetailList.TotalPages); response.Data = billDetailList; } catch (Exception ex) { _logger.LogError(ex.StackTrace); response.Success = false; response.Message = ex.Message; } return(Ok(response)); }
public async Task <IActionResult> GetBillId(BillDetailModel billMasterId) { ServiceResponseModel <IEnumerable <BillDetailModel> > response = new ServiceResponseModel <IEnumerable <BillDetailModel> >(); try { if (string.IsNullOrWhiteSpace(billMasterId.CompCode)) { throw new ArgumentNullException("CompCode is required"); } if (string.IsNullOrWhiteSpace(billMasterId.AccYear)) { throw new ArgumentNullException("AccYear is required"); } if (string.IsNullOrWhiteSpace(billMasterId.BillId)) { throw new ArgumentNullException("BillId is required"); } response = await _billDetailService.GetBillId(billMasterId); if (response.Data == null) { return(NotFound(response)); } } catch (Exception ex) { _logger.LogError(ex.StackTrace); response.Success = false; response.Message = ex.Message; } return(Ok(response)); }
public async Task <ServiceResponseModel <BillDetailModel> > Add(BillDetailModel newBillDetailModell) { ServiceResponseModel <BillDetailModel> serviceResponse = new ServiceResponseModel <BillDetailModel>(); BillDetail billDetail = _mapper.Map <BillDetail>(newBillDetailModell); await UnitOfWork.BillDetails.AddAsync(billDetail); await UnitOfWork.Complete(); serviceResponse.Data = newBillDetailModell; return(serviceResponse); }
public async Task <ServiceResponseModel <BillDetailModel> > Delete(BillDetailModel billBillDetailModel) { ServiceResponseModel <BillDetailModel> serviceResponse = new ServiceResponseModel <BillDetailModel>(); BillDetail delbillBillDetail = await UnitOfWork.BillDetails.SingleOrDefaultAsync(a => a.CompCode == billBillDetailModel.CompCode && a.AccYear == billBillDetailModel.AccYear && a.BillId == billBillDetailModel.BillId && a.ItemSr == billBillDetailModel.ItemSr); UnitOfWork.BillDetails.Remove(delbillBillDetail); await UnitOfWork.Complete(); serviceResponse.Data = billBillDetailModel; return(serviceResponse); }
public async Task <ServiceResponseModel <BillDetailModel> > Edit(BillDetailModel editBillDetailModel) { ServiceResponseModel <BillDetailModel> serviceResponse = new ServiceResponseModel <BillDetailModel>(); BillDetail editbillBillDetail = await UnitOfWork.BillDetails.SingleOrDefaultAsync(a => a.CompCode == editBillDetailModel.CompCode && a.AccYear == editBillDetailModel.AccYear && a.BillId == editBillDetailModel.BillId && a.ItemSr == editBillDetailModel.ItemSr); _mapper.Map <BillDetailModel, BillDetail>(editBillDetailModel, editbillBillDetail); UnitOfWork.BillDetails.Update(editbillBillDetail); await UnitOfWork.Complete(); serviceResponse.Data = editBillDetailModel; return(serviceResponse); }
public async Task <IActionResult> Edit([FromBody] BillDetailModel editBillDetailModel) { ServiceResponseModel <BillDetailModel> response = new ServiceResponseModel <BillDetailModel>(); try { if (string.IsNullOrWhiteSpace(editBillDetailModel.CompCode)) { throw new ArgumentNullException("CompCode is required"); } if (string.IsNullOrWhiteSpace(editBillDetailModel.AccYear)) { throw new ArgumentNullException("AccYear is required"); } if (string.IsNullOrWhiteSpace(editBillDetailModel.BillId)) { throw new ArgumentNullException("BillId is required"); } if (editBillDetailModel.ItemSr < 0) { throw new ArgumentNullException("ItemSr is required"); } response = await _billDetailService.Edit(editBillDetailModel); if (response.Data == null) { return(NotFound(response)); } } catch (Exception ex) { _logger.LogError(ex.StackTrace); response.Success = false; response.Message = ex.Message; } return(Ok(response)); }
public async Task <PagedList <BillDetail> > GetAll(PageParams pageParams, BillDetailModel getBillDetailModel) { var query = _context.BillDetails .Where(a => a.CompCode == getBillDetailModel.CompCode && a.AccYear == getBillDetailModel.AccYear) .AsQueryable(); switch (getBillDetailModel.OrderBy) { case "billId": query = query.OrderBy(c => c.CompCode).ThenBy(c => c.AccYear).ThenBy(c => c.BillId).ThenBy(c => c.ItemSr); break; case "vouNo": query = query.OrderBy(c => c.CompCode).ThenBy(c => c.AccYear).ThenBy(c => c.BillId).ThenBy(c => c.ItemSr); break; default: query = query.OrderBy(c => c.CompCode).ThenBy(c => c.AccYear).ThenBy(c => c.BillId).ThenBy(c => c.ItemSr); break; } return(await PagedList <BillDetail> .CreateAsync(query, pageParams.PageNumber, pageParams.PageSize)); }
public static Highcharts GetSummaryChart(BillDetailModel bill) { return BuildPieChart("BillSummaryChart", GetSummarySeriesData(bill), @"{point.name}: £{point.y:.2f}", @"<span style=""color:{point.color}"">{point.id}</span><br/>"); }
private static Series GetSummarySeriesData(BillDetailModel bill) { return new Series { Name = "Bill Summary", Data = new Data(new[] { new Point { Name = "Package", Y = ConvertNumber(bill.Package.Total) //Drilldown = new Drilldown() //{ // Name = "Subscriptions", // Data = new Data(bill.Package.Subscriptions // .Select(s => new Point {Name = s.Name, Y = ConvertNumber(s.Cost)}) // .ToArray()) //} }, new Point { Name = "Call Charges", Y = ConvertNumber(bill.CallCharges.Total) //Drilldown = new Drilldown() //{ // Name = "Calls", // Data = new Data(bill.CallCharges.Calls // .GroupBy(call => call.Called) // .Select( // callGroup => // new Point // { // Name = callGroup.Key, // Y = ConvertNumber(callGroup.Sum(call => call.Cost)) // }) // .ToArray()) //} }, new Point { Name = "Sky Store", Y = ConvertNumber(bill.SkyStore.Total) //Drilldown = new Drilldown() //{ // Name = "Sky Store", // Data = new Data(new Point[] // { // new Point // { // Name = "Rentals", // Y = ConvertNumber(bill.SkyStore.Rentals.Sum(item => item.Cost)), // //Drilldown = new Drilldown() // //{ // // Name = "Rentals", // // Data = new Data(bill.SkyStore.Rentals // // .Select(rental => new Point{Name = CleanText(rental.Title), Y = ConvertNumber(rental.Cost)}) // // .ToArray()) // //} // }, // new Point // { // Name = "Buy And Keep", // Y = ConvertNumber(bill.SkyStore.BuyAndKeep.Sum(item => item.Cost)), // //Drilldown = new Drilldown() // //{ // // Name = "Buy And Keep", // // Data = new Data(bill.SkyStore.BuyAndKeep // // .Select(bk => new Point {Name = CleanText(bk.Title), Y = ConvertNumber(bk.Cost)}) // // .ToArray()) // //} // } // }) //} } }) }; }
/// <summary> /// add bill to database /// </summary> /// <param name="totalPay"></param> /// <returns></returns> public ActionResult PaymentProcess(int totalPay) { var loginSession = Session["userLogin"]; if (loginSession != null) // login already { var user = (User)loginSession; //creat new bill object and set data Bill b = new Bill(); b.b_address = user.u_address; b.b_purchaseDate = DateTime.Now; b.b_status = "Processing"; b.b_total = totalPay; b.u_id = user.u_id; try { //insert bill to db var billID = new BillModel().InsertBill(b); var cart = (List <CartItem>)Session[cartSession]; foreach (var item in cart) { //insert bill detail var billDetail = new BillDetail(); billDetail.b_id = billID; var bdm = new BillDetailModel(); //quantity = 1 if (item.Quantity == 1) { // product is Pet food if (item.productID.StartsWith("PFD")) { billDetail.pf_id = item.productID; bdm.InsertBillDetail(billDetail); } // product is Pet if (item.productID.StartsWith("PET")) { billDetail.p_id = item.productID; bdm.InsertBillDetail(billDetail); } // product is Pet medicine if (item.productID.StartsWith("PMD")) { billDetail.pm_id = item.productID; bdm.InsertBillDetail(billDetail); } // product is Pet food if (item.productID.StartsWith("PTS")) { billDetail.pt_id = item.productID; bdm.InsertBillDetail(billDetail); } } else //quantity > 1,it will add quantity time that product { for (int i = 0; i < item.Quantity; i++) { // product is Pet food if (item.productID.StartsWith("PFD")) { billDetail.pf_id = item.productID; bdm.InsertBillDetail(billDetail); } // product is Pet if (item.productID.StartsWith("PET")) { billDetail.p_id = item.productID; bdm.InsertBillDetail(billDetail); } // product is Pet medicine if (item.productID.StartsWith("PMD")) { billDetail.pm_id = item.productID; bdm.InsertBillDetail(billDetail); } // product is Pet toys if (item.productID.StartsWith("PTS")) { billDetail.pt_id = item.productID; bdm.InsertBillDetail(billDetail); } } } } Session[cartSession] = null; } catch { return(Redirect("/failure")); } return(Redirect("/complete")); } else //move to login page if there is not yet login. { return(RedirectToAction("Index", "Accounts")); } }
public static BillDetail ToBillDetail(this BillDetailModel entity) { return(entity.MapTo <BillDetailModel, BillDetail>()); }
public async Task <ServiceResponseModel <IEnumerable <BillDetailModel> > > GetAll(BillDetailModel getBillDetailModel) { ServiceResponseModel <IEnumerable <BillDetailModel> > serviceResponse = new ServiceResponseModel <IEnumerable <BillDetailModel> >(); IEnumerable <BillDetail> editbillBillDetail = await UnitOfWork.BillDetails.FindAsync(a => a.CompCode == getBillDetailModel.CompCode && a.AccYear == getBillDetailModel.AccYear); IEnumerable <BillDetailModel> billDetailModel = _mapper.Map <IEnumerable <BillDetailModel> >(editbillBillDetail); serviceResponse.Data = billDetailModel; return(serviceResponse); }