Esempio n. 1
0
        public async Task <IActionResult> Create([FromBody] CreateOfferRequest offer)
        {
            var Offers = new Offers
            {
                ArabicDesc  = offer.ArabicDesc,
                EnglishDesc = offer.EnglishDesc,
                offerPrice  = offer.offerPrice,
                ImgUrl      = offer.ImgUrl,
                ProductId   = offer.ProductId,
                status      = offer.status
            };

            var status = await _OffersService.CreateOffersAsync(Offers);

            if (status == -1)
            {
                return(Conflict(new ErrorResponse
                {
                    message = "Dublicate Entry",
                    status = Conflict().StatusCode
                }));
            }

            if (status == 1)
            {
                await _productService.UpdateProductSalePriceAsync(offer.ProductId, offer.offerPrice);

                var response = new OfferResponse {
                    Id = Offers.Id
                };
                return(Ok(response));
            }
            return(NotFound(new ErrorResponse
            {
                message = "Not Found",
                status = NotFound().StatusCode
            }));
        }