Beispiel #1
0
        public async Task <bool> SaveSale(SalesRequest sale)
        {
            try
            {
                if (!String.IsNullOrEmpty(sale.idSale.ToString()))
                {
                    _context.Sales.Update(sale);
                }
                else
                {
                    await _context.Sales.AddAsync(sale);
                }


                if (await _context.SaveChangesAsync() != 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Beispiel #2
0
        public HttpResponseMessage GetMapSalesByProduct([FromUri] SalesRequest model, int productId)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }

            ItemsResponse <SalesMap> response = new ItemsResponse <SalesMap>();

            response.Items = _salesAnalyticsService.GetSalesMapByProduct(model, productId);
            return(Request.CreateResponse(response));
        }
Beispiel #3
0
        public HttpResponseMessage Get([FromUri] SalesRequest model)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }

            ItemsResponse <BaseProductSales> response = new ItemsResponse <BaseProductSales>();

            response.Items = _salesAnalyticsService.Get(model);
            return(Request.CreateResponse(response));
        }
        public async Task <BaseResponse <bool> > SaveSale(SalesRequest sale)
        {
            BaseResponse <bool> res = new BaseResponse <bool>();

            res.response = await _salesRepository.SaveSale(sale);

            res.msg = "Se guardó la venta con exito!";
            if (!res.response)
            {
                res.msg = "Error al intentar guardar el cliente";
            }

            return(res);
        }
 public async Task <JsonResult> SaveSale(SalesRequest sale)
 {
     return(new JsonResult(await _salesBusiness.SaveSale(sale)));
 }