public async Task <OrderConfirmation> CreateOrderAsync(Order order) { order.PaymentMethod.TotalPrice = GetPrice(order.Products); await db.Orders.AddAsync(order); await db.SaveChangesAsync(); var orderConfirmation = mapper.Map <OrderConfirmation>(order); return(orderConfirmation); }
public async Task CreateProductAsync(Product product) { string path = "/Images/" + product.UploadedFile.FileName; using (var fileStream = new FileStream(_appEnvironment.WebRootPath + path, FileMode.Create)) { await product.UploadedFile.CopyToAsync(fileStream); } var productModel = new Product { ProductName = product.ProductName, ProductDescription = product.ProductDescription, Price = product.Price, ProductWeight = product.ProductWeight, Name = product.UploadedFile.FileName, Path = path, CategoryId = product.CategoryId }; await db.Products.AddAsync(productModel); await db.SaveChangesAsync(); }
public async Task CreateCategoryAsync(Category category) { await db.Categories.AddAsync(category); await db.SaveChangesAsync(); }