public async Task <Category> AddCategory(Category category) { return(await _categoryRepository.AddAsync(category)); }
public async Task <TEntity> AddAsync(TEntity entity) { var response = await _repository.AddAsync(entity).ConfigureAwait(false); return(response); }
public async Task <string> AddCreditCardAsync(CreditCard creditCard) { await genericRepository.AddAsync(creditCard); return("success"); }
public async Task CreateComponentAsync(ComponentDTO component) { await componentRepository.AddAsync(mapper.Map <ComponentDTO, ComponentDB>(component)); }
public async Task <T> AddAsync(T entity) { return(await _repository.AddAsync(entity)); }
public async Task <IActionResult> CheckOut(CheckoutViewModel model) { ISession session = HttpContext.Session; Customer customer = await userManager.GetUserAsync(User); Tube tubeTemp; int adressId = 0; //update shipping, billing address in customer try { adressId = await UpdateCustomerAndAddresses(model); } catch (Exception ex) { logger.LogInformation(ex.Message); logger.LogInformation($"Failed updating customer and adresses"); } if (adressId == 0) { logger.LogInformation($"Failed updating customer and adresses"); return(RedirectToAction(nameof(ReturnCart))); } //new invoice Invoice invoice = new Invoice() { OrderDate = DateTime.Now, CustomerId = customer.Id, ShippingAddressId = adressId, }; //get coupon string couponName = session.GetString("Coupon"); Coupon coupon = await coupons.FindAsync(x => x.CouponName.Equals(couponName)) ?? new Coupon(); if (coupon.CouponId != 0) { invoice.CouponId = coupon.CouponId; } //get shoppingcart items ShoppingCart shoppingCart = new ShoppingCart(); shoppingCart.ShoppingCartId = session.GetString("ShoppingCartId"); List <ShoppingCartItem> sessionList = JsonConvert.DeserializeObject <List <ShoppingCartItem> >( session.GetString("ShoppingCartItems")); if (sessionList.Count() == 0) { logger.LogInformation($"List in cart is empty???"); return(RedirectToAction(nameof(ReturnCart))); } //get cartitems => to invoiceinfo in new invoice try { foreach (var item in sessionList) { tubeTemp = await tubes.GetAsync(item.TubeId); invoice.InvoicesInfo.Add(new InvoiceInfo() { TubeId = item.TubeId, Price = tubeTemp.Price, Quantity = item.Quantity, Discount = tubeTemp.Discount }); } } catch (Exception ex) { logger.LogInformation($"Adding tubes to order failed"); logger.LogInformation(ex.Message); modalNotification.AddNotificationSweet("Fail", NotificationType.error, "Please try later!"); } //total cost for invoice foreach (var item in invoice.InvoicesInfo) { invoice.Total += item.Quantity * item.Price * (1 - item.Discount); } invoice.Total *= (1 - coupon.CouponValue); //saving invoice try { var invoiceResult = await invoices.AddAsync(invoice); } catch (Exception ex) { logger.LogInformation($"Inovice saving failed"); logger.LogInformation(ex.Message); modalNotification.AddNotificationSweet("Fail", NotificationType.error, "Please try later!"); } //decrease number of tubes in stock try { foreach (var item in invoice.InvoicesInfo) { tubeTemp = await tubes.GetAsync(item.TubeId); tubeTemp.Quantity -= item.Quantity; var tubeResult = await tubes.UpdateAsync(tubeTemp); } } catch (Exception ex) { logger.LogInformation($"Tube minus quantity failed"); logger.LogInformation(ex.Message); modalNotification.AddNotificationSweet("Fail", NotificationType.error, "Please try later!"); } //clear shoppingcart HttpContext.Session.Remove("ShoppingCartId"); HttpContext.Session.Remove("ShoppingCartItems"); modalNotification.AddNotificationSweet("Invoice", NotificationType.success, "Invoice created. Now you can pay it"); return(RedirectToAction(nameof(InvoiceController.Index), "Invoice")); }
public async Task <MenuItem> AddMenuItem(MenuItem menuItem) { return(await _menuItemRepository.AddAsync(menuItem)); }
public async Task <Size> CreateSizeAsync(Size size) { var result = await _context.AddAsync(size); return(result); }
public virtual async Task <TModel> AddAsync(TModel model) { var result = await Repository.AddAsync(this.Mapper.Map <TEntity>(model)); return(this.Mapper.Map <TModel>(result)); }
public async Task AddAsync(TEntity entity) { await _genericRepository.AddAsync(entity); }
public async Task <Category> CreateCategoryAsync(Category category) { var result = await _context.AddAsync(category); return(result); }
public virtual async Task <TEntity> AddAsync(TEntity model) { return(await Repository.AddAsync(model)); }
/// <summary> /// Create method, /// creates a new VehicleMake using Generic Repository. /// </summary> /// <param name="entity">Model, type of IVehicleMake.</param> public async Task AddVehicleMakeAsync(IVehicleMake entity) { await Repository.AddAsync(AutoMapper.Mapper.Map <VehicleMakeEntity>(entity)); }
public async Task <Status> CreateStatusAsync(Status status) { var result = await _context.AddAsync(status); return(result); }