/// <summary> /// Method to convert bottle return to Br payment model /// </summary> /// <param name="bottleReturn">Bottle return model</param> /// <returns>BR payment</returns> private BR_Payment GetBrPayment(BottleReturnInputModel bottleReturn) { var brPayments = new BR_Payment { Sale_Num = bottleReturn.SaleNumber, TillNumber = bottleReturn.TillNumber, Amount = bottleReturn.Amount, RegisterNumber = bottleReturn.RegisterNumber }; foreach (var bottle in bottleReturn.Bottles) { brPayments.Br_Lines.AddLine(bottle.LineNumber, bottle, ""); } return(brPayments); }
public HttpResponseMessage SaveBottleReturns([FromBody] BottleReturnInputModel bottleReturn) { var dateStart = DateTime.Now; _performancelog.Debug($"Start,BottleController,SaveBottleReturns,{string.Empty},{dateStart:hh.mm.ss.ffffff}"); BR_Payment brPayments = GetBrPayment(bottleReturn); ErrorMessage errorMessage; bool openDrawer; Report fs; var sale = _bottleManager.SaveBottleReturn(brPayments, out errorMessage, out fs, out openDrawer); if (!string.IsNullOrEmpty(errorMessage.MessageStyle.Message)) { return(Request.CreateResponse(errorMessage.StatusCode, new ErrorResponse { Error = errorMessage.MessageStyle })); } var completePaymentResponseModel = new CompleteBottleReturnResponseModel { NewSale = new NewSale { SaleNumber = sale.Sale_Num, TillNumber = sale.TillNumber, Customer = sale.Customer.Name }, OpenCashDrawer = openDrawer, CustomerDisplay = sale.CustomerDisplay }; if (fs != null) { completePaymentResponseModel.PaymentReceipt = new ReportModel { ReportName = fs.ReportName, ReportContent = fs.ReportContent, Copies = fs.Copies }; } _performancelog.Debug($"End,BottleController,SaveBottleReturns,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}"); return(Request.CreateResponse(HttpStatusCode.OK, completePaymentResponseModel)); }