public async Task <bool> EditPrice(long materialId, NewPriceDto newPriceDto) { var material = await GetMaterialById(materialId); if (material == null) { return(false); } var res = material.PricePSM.EditPrice(newPriceDto.Price, newPriceDto.Timestamp); if (!res) { return(false); } return(await UpdateMaterial(material)); }
public async Task <bool> EditPrice(long finishId, NewPriceDto newPriceDto) { var finish = await GetFinishById(finishId); if (finish == null) { return(false); } var res = finish.PricePSM.EditPrice(newPriceDto.Price, newPriceDto.Timestamp); if (!res) { return(false); } return(await UpdateFinish(finish)); }
public async Task <BaseResponseDto> AddPrice(NewPriceDto newPrice) { try { var product = await GetProduct(newPrice.ProductId); if (product.ProductPrices.Count(x => x.ShopUserId == newPrice.ShopUserId) > 0) { product.ProductPrices.FirstOrDefault(x => x.ShopUserId == newPrice.ShopUserId).Price = newPrice.Price; product.ProductPrices.FirstOrDefault(x => x.ShopUserId == newPrice.ShopUserId).Discount = newPrice.Discount; } else { var price = new ProductPrice() { ShopUserId = newPrice.ShopUserId, Price = newPrice.Price, Discount = newPrice.Discount }; product.ProductPrices.Add(price); } await _context.SaveChangesAsync(); return(new BaseResponseDto() { IsSuccess = true, Error = "" }); } catch (Exception ex) { return(new BaseResponseDto() { IsSuccess = false, Error = "به دلایلی قادر به ذخیره سازی نیست لطفا پس از بررسی اطلاعات دوباره تلاش کنید..." }); } }
public async Task <IActionResult> AddAnticipatedPrice([FromRoute] long userID, [FromRoute] long materialId, [FromBody] NewPriceDto newPriceDto) { try { var res = await _repositoryWrapper.Material.AddAnticipatedPrice(materialId, newPriceDto); if (!res) { return(StatusCode(400, "Not possible to edit price")); } return(Ok(new { message = "Edited price to", newPrice = newPriceDto })); } catch (Exception ex) { return(StatusCode(500, "Internal server error " + ex)); } }
public async Task <BaseResponseDto> AddPrice(NewPriceDto newPrice) { return(await _productRepository.AddPrice(newPrice)); }