public override async Task <ProductSold> FindAsync(params object[] id) { var res = ProductSoldMapper.MapFromDAL(await Uow.ProductsSold.FindAsync(id)); res.Sale = SaleMapper.MapFromDAL(await Uow.Sales.FindAsync(res.SaleId)); return(res); }
public HttpResponseMessage DeactivateGivexCard([FromBody] ActivateGivexModel givexModel) { var dateStart = DateTime.Now; _performancelog.Debug($"Start,GivexController,DeactivateGivexCard,{string.Empty},{dateStart:hh.mm.ss.ffffff}"); ErrorMessage errorMessage; HttpResponseMessage responseMessage; var cardNumber = givexModel.GivexCardNumber; if (!ValidateGivexCard(ref cardNumber, out responseMessage)) { return(responseMessage); } givexModel.GivexCardNumber = cardNumber; if (!ValidateStockCode(givexModel.StockCode, out responseMessage)) { return(responseMessage); } string userCode; HttpResponseMessage httpResponseMessage; if (GetUserCode(out userCode, out httpResponseMessage)) { return(httpResponseMessage); } Report giveReceipt; var sale = _givexManager.DeactivateGivexCard(givexModel.GivexCardNumber, givexModel.GivexPrice, userCode, givexModel.TillNumber, givexModel.SaleNumber, givexModel.StockCode, out giveReceipt, out errorMessage); if (!string.IsNullOrEmpty(errorMessage.MessageStyle.Message)) { return(Request.CreateResponse(errorMessage.StatusCode, new ErrorResponse { Error = errorMessage.MessageStyle })); } var editLines = _saleManager.CheckEditOptions(sale.Sale_Lines, userCode); var enableButtons = _saleManager.EnableCashButton(sale, userCode); var userCanWriteOff = _saleManager.EnableWriteOffButton(userCode); var saleModel = SaleMapper.CreateSaleModel(sale, editLines, enableButtons, userCanWriteOff); var response = new GivexResponseModel { Sale = saleModel, Receipt = giveReceipt }; _performancelog.Debug($"End,GivexController,DeactivateGivexCard,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}"); return(Request.CreateResponse(HttpStatusCode.OK, response)); }
public HttpResponseMessage GetSale(int saleNumber, int tillNumber) { var dateStart = DateTime.Now; _performancelog.Debug($"Start,ReturnSaleController,GetSale,{string.Empty},{dateStart:hh.mm.ss.ffffff}"); string userCode; HttpResponseMessage httpResponseMessage; if (GetUserCode(out userCode, out httpResponseMessage)) { return(httpResponseMessage); } ErrorMessage message; var sale = _returnSaleManager.GetSale(saleNumber, tillNumber, out message); if (!string.IsNullOrEmpty(message.MessageStyle.Message)) { _performancelog.Debug($"End,ReturnSaleController,GetSale,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}"); return(Request.CreateResponse(HttpStatusCode.NotFound, new ErrorResponse { Error = message.MessageStyle })); } var editLines = _saleManager.CheckEditOptions(sale.Sale_Lines, userCode); var enableButtons = _saleManager.EnableCashButton(sale, userCode); var userCanWriteOff = _saleManager.EnableWriteOffButton(userCode); var saleModel = SaleMapper.CreateSaleModel(sale, editLines, enableButtons, userCanWriteOff); _performancelog.Debug($"End,ReturnSaleController,GetSale,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}"); return(Request.CreateResponse(HttpStatusCode.OK, saleModel)); }
public HttpResponseMessage InitializeSale(int tillNumber, int registerNumber) { var dateStart = DateTime.Now; _performancelog.Debug($"Start,SaleController,InitializeSale,{string.Empty},{dateStart:hh.mm.ss.ffffff}"); ErrorMessage message; string userCode; HttpResponseMessage httpResponseMessage; if (GetUserCode(out userCode, out httpResponseMessage)) { return(httpResponseMessage); } var sale = _saleManager.InitializeSale(tillNumber, registerNumber, userCode, out message); if (message?.MessageStyle?.Message != null) { return(Request.CreateResponse(HttpStatusCode.Conflict, message)); } if (sale != null) { var editLines = _saleManager.CheckEditOptions(sale.Sale_Lines, userCode); var enableButton = _saleManager.EnableCashButton(sale, userCode); var userCanWriteOff = _saleManager.EnableWriteOffButton(userCode); var saleModel = SaleMapper.CreateSaleModel(sale, editLines, enableButton, userCanWriteOff); _performancelog.Debug($"End,SaleController,InitializeSale,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}"); return(Request.CreateResponse(HttpStatusCode.OK, saleModel)); } return(null); }
public async Task <List <DTO.DomainLikeDTO.Sale> > AllAsyncByShop(int?shopId, string order, string searchFor, int?pageIndex, int?pageSize) { var query = RepositoryDbSet .Include(a => a.Description).ThenInclude(t => t.Translations) .Include(a => a.AppUser) .Include(a => a.ProductsSold).ThenInclude(a => a.Product).ThenInclude(aa => aa.ProductName) .ThenInclude(t => t.Translations) .Include(a => a.ProductsSold).ThenInclude(a => a.Product).ThenInclude(aa => aa.Length) .ThenInclude(t => t.Translations) .Include(a => a.ProductsSold).ThenInclude(a => a.Product).ThenInclude(aa => aa.Weight) .ThenInclude(t => t.Translations) .Include(a => a.ProductsSold).ThenInclude(a => a.Product).ThenInclude(aa => aa.ManuFacturerItemCode) .ThenInclude(t => t.Translations) .Include(a => a.ProductsSold).ThenInclude(a => a.Product).ThenInclude(aa => aa.ShopCode) .ThenInclude(t => t.Translations) .Where(p => p.AppUser.ShopId == shopId) .AsQueryable(); query = Search(query, searchFor); query = Order(query, order); if (pageIndex != null && pageSize != null) { query = query.Skip((pageIndex.Value - 1) * pageSize.Value).Take(pageSize.Value); } var temp = await query.ToListAsync(); var res = temp.Select(e => SaleMapper.MapFromDomain(e)).ToList(); return(res); }
public HttpResponseMessage ReturnSaleItems([FromBody] ReturnSaleModel model) { var dateStart = DateTime.Now; _performancelog.Debug($"Start,ReturnSaleController,returnItems,{string.Empty},{dateStart:hh.mm.ss.ffffff}"); ErrorMessage message; List <ErrorMessage> saleLineMessages; string userCode; HttpResponseMessage httpResponseMessage; if (GetUserCode(out userCode, out httpResponseMessage)) { return(httpResponseMessage); } var user = CacheManager.GetUser(userCode) ?? _loginManager.GetUser(userCode); if (model.SaleLines == null || model.SaleLines.Length <= 0) { return(Request.CreateResponse(HttpStatusCode.BadRequest, new ErrorResponse { Error = new MessageStyle { Message = Resource.LineRequired, MessageType = MessageType.OkOnly } })); } var sale = _returnSaleManager.ReturnSaleItems(user, model.SaleTillNumber, model.TillNumber, model.SaleNumber, model.SaleLines, model.IsCorrection, model.ReasonType, model.ReasonCode, out message, out saleLineMessages); if (!string.IsNullOrEmpty(message.MessageStyle.Message)) { _performancelog.Debug($"End,ReturnSaleController,returnItems,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}"); return(Request.CreateResponse(HttpStatusCode.BadRequest, new ErrorResponse { Error = message.MessageStyle })); } var editLines = _saleManager.CheckEditOptions(sale.Sale_Lines, userCode); var messages = new List <object>(); if (saleLineMessages.Count > 0) { messages.AddRange(saleLineMessages.Select(saleLineMessage => new { error = saleLineMessage.MessageStyle, })); } var enableButtons = _saleManager.EnableCashButton(sale, userCode); var userCanWriteOff = _saleManager.EnableWriteOffButton(userCode); var saleModel = messages.Count > 0 ? SaleMapper.CreateSaleModel(sale, editLines, enableButtons, userCanWriteOff, messages) : SaleMapper.CreateSaleModel(sale, editLines, enableButtons, userCanWriteOff); _performancelog.Debug($"End,ReturnSaleController,returnItems,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}"); return(Request.CreateResponse(HttpStatusCode.OK, saleModel)); }
public HttpResponseMessage SearchLoyaltyCustomer(string searchTerm, int tillNumber, int saleNumber, int pageIndex = 1, int pageSize = 100) { var dateStart = DateTime.Now; _performancelog.Debug($"Start,CustomerController,SearchLoyaltyCustomer,{string.Empty},{DateTime.Now:hh.mm.ss.ffffff}"); int totalResults; var customers = _customerManager.SearchLoyaltyCustomer(searchTerm, out totalResults, pageIndex, pageSize); if (totalResults == -999) { string userCode; HttpResponseMessage httpResponseMessage; if (GetUserCode(out userCode, out httpResponseMessage)) { return(httpResponseMessage); } var firstOrDefault = customers.FirstOrDefault(); if (firstOrDefault != null) { var code = firstOrDefault.Code; ErrorMessage error; var sale = _saleManager.SetCustomer(code, saleNumber, tillNumber, userCode, 0, searchTerm, out error); if (!string.IsNullOrEmpty(error.MessageStyle.Message)) { return(Request.CreateResponse(HttpStatusCode.BadRequest, new ErrorResponse { Error = error.MessageStyle })); } if (sale != null) { var editLines = _saleManager.CheckEditOptions(sale.Sale_Lines, userCode); var enableButtons = _saleManager.EnableCashButton(sale, userCode); var userCanWriteOff = _saleManager.EnableWriteOffButton(userCode); var saleModel = SaleMapper.CreateSaleModel(sale, editLines, enableButtons, userCanWriteOff); return(Request.CreateResponse(HttpStatusCode.Accepted, saleModel)); } } } if (totalResults == 0) { return(Request.CreateResponse(HttpStatusCode.BadRequest, new ErrorResponse { Error = new MessageStyle { Message = Resource.CustomerNotExists, MessageType = MessageType.OkOnly } })); } var listCust = GetLoyaltyCustomerResponseModels(customers); _performancelog.Debug($"End,CustomerController,SearchLoyaltyCustomer,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}"); return(Request.CreateResponse(HttpStatusCode.OK, listCust)); }
public async Task <List <DTO.DomainLikeDTO.Sale> > AllAsyncByShopAndUserId(int?shopId, int userId) { return(await RepositoryDbSet .Include(a => a.Description).ThenInclude(t => t.Translations) .Include(a => a.AppUser) .Where(p => p.AppUser.ShopId == shopId) .Where(p => p.AppUserId == userId) .Select(e => SaleMapper.MapFromDomain(e)).ToListAsync()); }
public Sale(SaleMapper mapper, DataAccess.DataAccess dac, int id_sale, double unit_price, int quantity, int concrete, DateTime sale_date) : this(mapper, dac) { this.id_sale = id_sale; //reservation_start_date = reservation_start; unit_price_sale = unit_price; quantity_product = quantity; concrete_sale = concrete; sale_date_completed = sale_date; }
public SaleController() { string constr = GlobalData.connectionString; _dataAccess = new DataAccess.DataAccess(constr); _saleMapper = new SaleMapper(_dataAccess); GetSales(); //GetReservations(); }
public async Task <ActionResult <PublicApi.v1.DTO.Sale> > GetSale(int id) { var sale = await _bll.Sales.GetAsyncByShopAndIdDTO(id, User.GetShopId()); if (sale == null) { return(NotFound()); } return(SaleMapper.MapFromBLL(sale)); }
public override async Task <List <ProductSold> > AllAsync() { var res = (await Uow.ProductsSold.AllAsync()).Select(e => ProductSoldMapper.MapFromDAL(e)).ToList(); foreach (var result in res) { result.Sale = SaleMapper.MapFromDAL(await Uow.Sales.FindAsync(result.SaleId)); } return(res); }
public async Task <IActionResult> PutSale(int id, PublicApi.v1.DTO.Sale sale) { if (!ModelState.IsValid || id != sale.Id || sale.AppUserId != User.GetUserId()) { return(BadRequest()); } _bll.Sales.Update(SaleMapper.MapFromExternal(sale)); await _bll.SaveChangesAsync(); return(NoContent()); }
public override async Task <List <Sale> > AllAsync() { return(await RepositoryDbSet .Include(a => a.Description).ThenInclude(t => t.Translations) .Include(a => a.AppUser) .Include(a => a.ProductsSold).ThenInclude(a => a.Product).ThenInclude(aa => aa.ProductName).ThenInclude(t => t.Translations) .Include(a => a.ProductsSold).ThenInclude(a => a.Product).ThenInclude(aa => aa.Length).ThenInclude(t => t.Translations) .Include(a => a.ProductsSold).ThenInclude(a => a.Product).ThenInclude(aa => aa.Weight).ThenInclude(t => t.Translations) .Include(a => a.ProductsSold).ThenInclude(a => a.Product).ThenInclude(aa => aa.ManuFacturerItemCode).ThenInclude(t => t.Translations) .Include(a => a.ProductsSold).ThenInclude(a => a.Product).ThenInclude(aa => aa.ShopCode).ThenInclude(t => t.Translations) .Select(e => SaleMapper.MapFromDomain(e)).ToListAsync()); }
public HttpResponseMessage DeleteUnCompletePrepay([FromBody] DeleteUnCompletePrepayModel model) { var dateStart = DateTime.Now; _performancelog.Debug($"Start,FuelPumpController,DeleteUnCompletePrepay,{string.Empty},{dateStart:hh.mm.ss.ffffff}"); ErrorMessage error; string userCode; HttpResponseMessage httpResponseMessage; if (GetUserCode(out userCode, out httpResponseMessage)) { return(httpResponseMessage); } var sale = _unCompletePrepayManager.DeleteUnCompletePrepay(model.PumpId, model.SaleNum, model.TillNumber, out error); if (!string.IsNullOrEmpty(error.MessageStyle.Message)) { return(Request.CreateResponse(HttpStatusCode.Conflict, new ErrorResponse { Error = error.MessageStyle, })); } object saleModel; var editLines = _saleManager.CheckEditOptions(sale.Sale_Lines, userCode); var enableButtons = _saleManager.EnableCashButton(sale, userCode); var userCanWriteOff = _saleManager.EnableWriteOffButton(userCode); if (!string.IsNullOrEmpty(error.MessageStyle.Message)) { var message = new { error = error.MessageStyle, }; var messages = new List <object> { message }; saleModel = SaleMapper.CreateSaleModel(sale, editLines, enableButtons, userCanWriteOff, messages); } else { saleModel = SaleMapper.CreateSaleModel(sale, editLines, enableButtons, userCanWriteOff); } _performancelog.Debug($"End,SaleController,DeleteUnCompletePrepay,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}"); return(Request.CreateResponse(HttpStatusCode.OK, saleModel)); }
public HttpResponseMessage AddFuelSaleFromBasket([FromBody] FuelBasketModel model) { // bool flag = false; //SaleModel s=null; WriteUDPData(DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss tt") + "Inside if 550"); var dateStart = DateTime.Now; _performancelog.Debug($"Start,FuelPumpController,AddPrepay,{string.Empty},{dateStart:hh.mm.ss.ffffff}"); ErrorMessage error; var accessToken = Request.GetFirstHeaderValueOrDefault <string>("authToken"); if (accessToken == null) { return(Request.CreateResponse( HttpStatusCode.BadRequest, new ErrorResponse { Error = new MessageStyle { Message = Resource.Error, MessageType = 0 } })); } var userCode = TokenValidator.GetUserCode(accessToken); WriteUDPData(DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss tt") + "Inside 572"); var sale = _fuelPumpManager.AddFuelSaleFromBasket(model.SaleNumber, model.TillNumber, model.RegisterNumber, model.ActivePump, model.BasketValue, out error); WriteUDPData(DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss tt") + "Inside if 574"); if (!string.IsNullOrEmpty(error.MessageStyle.Message)) { return(Request.CreateResponse(HttpStatusCode.Conflict, new ErrorResponse { Error = error.MessageStyle, })); } var editLines = _saleManager.CheckEditOptions(sale.Sale_Lines, userCode); var enableButton = _saleManager.EnableCashButton(sale, userCode); var userCanWriteOff = _saleManager.EnableWriteOffButton(userCode); var saleModel = SaleMapper.CreateSaleModel(sale, editLines, enableButton, userCanWriteOff); _performancelog.Debug($"End,FuelPumpController,AddPrepay,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}"); WriteUDPData(DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss tt") + "Inside if 584"); // s = saleModel; return(Request.CreateResponse(HttpStatusCode.OK, saleModel)); }
public override async Task <Sale> FindAsync(params object[] id) { var sale = await RepositoryDbSet.FindAsync(id); return(SaleMapper.MapFromDomain(await RepositoryDbSet.Where(a => a.Id == sale.Id) .Include(a => a.Description).ThenInclude(t => t.Translations) .Include(a => a.AppUser) .Include(a => a.ProductsSold).ThenInclude(a => a.Product).ThenInclude(aa => aa.ProductName).ThenInclude(t => t.Translations) .Include(a => a.ProductsSold).ThenInclude(a => a.Product).ThenInclude(aa => aa.Length).ThenInclude(t => t.Translations) .Include(a => a.ProductsSold).ThenInclude(a => a.Product).ThenInclude(aa => aa.Weight).ThenInclude(t => t.Translations) .Include(a => a.ProductsSold).ThenInclude(a => a.Product).ThenInclude(aa => aa.ManuFacturerItemCode).ThenInclude(t => t.Translations) .Include(a => a.ProductsSold).ThenInclude(a => a.Product).ThenInclude(aa => aa.ShopCode).ThenInclude(t => t.Translations) .FirstOrDefaultAsync())); }
public HttpResponseMessage AddPrepay([FromBody] AddPrepayModel model) { var dateStart = DateTime.Now; _performancelog.Debug($"Start,FuelPumpController,AddPrepay,{string.Empty},{dateStart:hh.mm.ss.ffffff}"); ErrorMessage error; var accessToken = Request.GetFirstHeaderValueOrDefault <string>("authToken"); if (accessToken == null) { return(Request.CreateResponse( HttpStatusCode.BadRequest, new ErrorResponse { Error = new MessageStyle { Message = Resource.Error, MessageType = 0 } })); } var userCode = TokenValidator.GetUserCode(accessToken); var sale = _fuelPrepayManager.AddPrepay(model.SaleNumber, model.TillNumber, model.ActivePump, model.Amount, model.FuelGrade, model.IsAmountCash, out error); if (!string.IsNullOrEmpty(error.MessageStyle.Message)) { return(Request.CreateResponse(HttpStatusCode.Conflict, new ErrorResponse { Error = error.MessageStyle, })); } if (sale != null) { var editLines = _saleManager.CheckEditOptions(sale.Sale_Lines, userCode); var enableButton = _saleManager.EnableCashButton(sale, userCode); var userCanWriteOff = _saleManager.EnableWriteOffButton(userCode); var saleModel = SaleMapper.CreateSaleModel(sale, editLines, enableButton, userCanWriteOff); _performancelog.Debug($"End,FuelPumpController,AddPrepay,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}"); return(Request.CreateResponse(HttpStatusCode.OK, saleModel)); } return(null); }
RecordOfSales ToRecordOfSales(Stockist stockist, IEnumerable <Subtransaction> subtransactions) { var stockistsSubtransactions = subtransactions.Where(x => x.Product.ProductCode.StartsWith(stockist.StockistCode)).ToList(); var rate = decimal.Divide(stockist.Commission.Rate, 100); if (stockistsSubtransactions.Count == 0) { return(new RecordOfSales { StockistCode = stockist.StockistCode, FirstName = stockist.Details.FirstName, Name = stockist.Details.DisplayName, EmailAddress = stockist.Details.EmailAddress, CustomMessage = string.Empty, StartDate = start, EndDate = end, Rate = rate, Sales = new List <Sale>().AsReadOnly(), Subtotal = 0, CommissionTotal = 0, Total = 0, }); } else { var sales = stockistsSubtransactions.Select(x => SaleMapper.FromTransaction(x, rate)).ToList(); var subtotal = sales.Sum(x => x.Subtotal); var commission = sales.Sum(x => x.Commission); return(new RecordOfSales { StockistCode = stockist.StockistCode, FirstName = stockist.Details.FirstName, Name = stockist.Details.DisplayName, EmailAddress = stockist.Details.EmailAddress, CustomMessage = string.Empty, StartDate = start, EndDate = end, Rate = rate, Sales = sales, Subtotal = subtotal, CommissionTotal = commission, Total = subtotal + commission, }); } }
public HttpResponseMessage UnSuspendSale(int saleNumber, int tillNumber) { var dateStart = DateTime.Now; _performancelog.Debug($"Start,SaleController,UnSuspendSale,{string.Empty},{dateStart:hh.mm.ss.ffffff}"); string userCode; HttpResponseMessage httpResponseMessage; if (GetUserCode(out userCode, out httpResponseMessage)) { return(httpResponseMessage); } if (saleNumber > 0) { ErrorMessage errorMessage; var sale = _suspendedSaleManger.UnsuspendSale(saleNumber, tillNumber, userCode, out errorMessage); if (!string.IsNullOrEmpty(errorMessage.MessageStyle.Message)) { return(Request.CreateResponse( HttpStatusCode.NotFound, new ErrorResponse { Error = errorMessage.MessageStyle })); } if (sale != null) { var editLines = _saleManager.CheckEditOptions(sale.Sale_Lines, userCode); var enableButtons = _saleManager.EnableCashButton(sale, userCode); var userCanWriteOff = _saleManager.EnableWriteOffButton(userCode); var saleModel = SaleMapper.CreateSaleModel(sale, editLines, enableButtons, userCanWriteOff); _performancelog.Debug( $"End,SaleController,UnSuspendSale,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}"); return(Request.CreateResponse(HttpStatusCode.OK, saleModel)); } } return(Request.CreateResponse(HttpStatusCode.BadRequest, new ErrorResponse { Error = new MessageStyle { Message = Resource.SaleNotExist, MessageType = (MessageType)16 } })); }
public SaleView OrderSale(CheckoutOrderView order) { if (order == null) { throw new ArgumentNullException("order", "Please inform checkout informations."); } if (String.IsNullOrEmpty(order.MerchantId)) { throw new ArgumentNullException("MerchantId."); } var checkout = SaleMapper.MapToDomain(order); var sale = saleService.OrderSale(checkout); SaleView saleView = SaleMapper.MapToView(sale); return(saleView); }
public HttpResponseMessage RemoveSaleLineItem(int tillNumber, int saleNumber, int lineNumber) { var dateStart = DateTime.Now; _performancelog.Debug($"Start,SaleController,RemoveSaleLineItem,{string.Empty},{dateStart:hh.mm.ss.ffffff}"); ErrorMessage error; string userCode; HttpResponseMessage httpResponseMessage; if (GetUserCode(out userCode, out httpResponseMessage)) { return(httpResponseMessage); } var sale = _saleManager.RemoveSaleLineItem(userCode, tillNumber, saleNumber, lineNumber, out error, true, true); if (!string.IsNullOrEmpty(error?.MessageStyle?.Message)) { var statusCode = error.StatusCode == 0 ? HttpStatusCode.BadRequest : error.StatusCode; return(Request.CreateResponse( statusCode, new ErrorResponse { Error = error.MessageStyle, })); } var editLines = _saleManager.CheckEditOptions(sale.Sale_Lines, userCode); var enableButtons = _saleManager.EnableCashButton(sale, userCode); var userCanWriteOff = _saleManager.EnableWriteOffButton(userCode); var saleModel = SaleMapper.CreateSaleModel(sale, editLines, enableButtons, userCanWriteOff); _performancelog.Debug($"End,SaleController,RemoveSaleLineItem,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}"); return(Request.CreateResponse(HttpStatusCode.OK, saleModel)); }
public async Task <List <SaleWithProductCount> > AllAsyncByShopDTO(int?shopId, string search, int?pageIndex, int?pageSize) { return((await Uow.Sales.AllAsyncByShopDTO(shopId, search, pageIndex, pageSize)).Select(e => SaleMapper.MapFromDAL(e)).ToList()); }
public HttpResponseMessage ReturnSale([FromBody] ReturnSaleModel model) { var dateStart = DateTime.Now; ErrorMessage message; List <ErrorMessage> saleLineMessages; _performancelog.Debug($"Start,ReturnSaleController,return,{string.Empty},{dateStart:hh.mm.ss.ffffff}"); string userCode; HttpResponseMessage httpResponseMessage; if (GetUserCode(out userCode, out httpResponseMessage)) { return(httpResponseMessage); } var user = CacheManager.GetUser(userCode) ?? _loginManager.GetUser(userCode); Report fs; string fileName; var sale = _returnSaleManager.ReturnSale(user, model.SaleNumber, model.TillNumber, model.SaleTillNumber, model.IsCorrection, model.ReasonType, model.ReasonCode, out message, out saleLineMessages, out fs, out fileName); if (!string.IsNullOrEmpty(message.MessageStyle.Message)) { _performancelog.Debug( $"End,ReturnSaleController,return,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}"); return(Request.CreateResponse(HttpStatusCode.BadRequest, new ErrorResponse { Error = message.MessageStyle })); } var editLines = _saleManager.CheckEditOptions(sale.Sale_Lines, userCode); var messages = new List <object>(); if (saleLineMessages.Count > 0) { messages.AddRange(saleLineMessages.Select(saleLineMessage => new { error = saleLineMessage.MessageStyle, })); } var enableButtons = _saleManager.EnableCashButton(sale, userCode); var userCanWriteOff = _saleManager.EnableWriteOffButton(userCode); var saleModel = messages.Count > 0 ? SaleMapper.CreateSaleModel(sale, editLines, enableButtons, userCanWriteOff, messages) : SaleMapper.CreateSaleModel(sale, editLines, enableButtons, userCanWriteOff); var returnSale = new ReturnSaleResponseModel { Sale = saleModel }; if (fs != null) { returnSale.Receipt = new ReportModel { ReportContent = fs.ReportName, ReportName = fs.ReportContent, Copies = 1 }; } _performancelog.Debug($"End,ReturnSaleController,return,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}"); return(Request.CreateResponse(HttpStatusCode.OK, returnSale)); }
public async Task <ActionResult <IEnumerable <PublicApi.v1.DTO.IdAndNameDTO.SaleIdName> > > GetSalesForUser() { var sale = (await _bll.Sales.GetAsyncByShopAndUserIdDTO(User.GetUserId(), User.GetShopId())).Select(e => SaleMapper.MapFromBLLIdName(e)).ToList(); return(sale); }
public async Task <ActionResult <IEnumerable <PublicApi.v1.DTO.Sale> > > GetSales(string search, int?pageIndex, int?pageSize) { if ((pageIndex != null && pageIndex < 1) || (pageSize != null && pageSize < 1)) { return(BadRequest()); } var sale = (await _bll.Sales.AllAsyncByShopDTO(User.GetShopId(), search, pageIndex, pageSize)).Select(e => SaleMapper.MapFromBLL(e)).ToList(); return(sale); }
public Sale(SaleMapper mapper, DataAccess.DataAccess dac) { _saleMapper = mapper; _dataAccess = dac; }
public async Task <List <Sale> > AllAsync(string order, string searchFor, int?pageIndex, int?pageSize) { return((await Uow.Sales.AllAsync(order, searchFor, pageIndex, pageSize)).Select(e => SaleMapper.MapFromDAL(e)).ToList()); }
public async Task <SaleWithProductCount> GetAsyncByShopAndIdDTO(int id, int?shopId) { return(SaleMapper.MapFromDAL(await Uow.Sales.GetAsyncByShopAndIdDTO(id, shopId))); }
public async Task <List <SaleWithProductCount> > GetAsyncByShopAndUserIdDTO(int userId, int?shopId) { return((await Uow.Sales.GetAsyncByShopAndUserIdDTO(userId, shopId)).Select(e => SaleMapper.MapFromDAL(e)).ToList()); }