public string AddOfflineCartItem(string userId, string cartId, string storeId, OfflineCartItemModel model) { // offline cart item foreach (var item in model.InventoryIds) { var sqlQry = string.Empty; sqlQry = GetInventoryPriceQry(item.ToString(), storeId); // get item price var itemPrice = _db.ExecuteScalar <decimal>(sqlQry); if (itemPrice > 0) { sqlQry = string.Empty; sqlQry = GetAddCartItemQry(); _db.Query(sqlQry, new { @cartId = cartId, @inventoryId = item, @quantity = 1, @amount = itemPrice, @createdDate = DateTime.Now, @createdBy = userId }); // update stock UpdateStockInventory(storeId, item.ToString(), "Add Inventory"); } else { throw _exception.ThrowException(System.Net.HttpStatusCode.BadRequest, "", string.Format("Inventarielistan {0} existerar inte.", item)); } } Payment(userId, storeId, cartId); // payment return("Köpta varor är inlagda."); }
public List <AddCartItemResponeseModel> AddCartItem(string userId, string cartId, string storeId, OfflineCartItemModel inventoryId) { List <AddCartItemResponeseModel> list = new List <AddCartItemResponeseModel>(); foreach (var item in inventoryId.InventoryIds) { // new cart item var sqlQry = string.Empty; sqlQry = GetInventoryPriceQry(item.ToString(), storeId); // get item price var itemPrice = _db.ExecuteScalar <decimal>(sqlQry); if (itemPrice > 0) { sqlQry = string.Empty; sqlQry = GetAddCartItemQry(); var cartItemId = _db.ExecuteScalar <long>(sqlQry, new { @cartId = cartId, @inventoryId = item, @quantity = 1, @amount = itemPrice, @createdDate = DateTime.Now, @createdBy = userId }); if (cartItemId > 0) { list.Add(new AddCartItemResponeseModel { InventoryId = item, CartItemId = cartItemId }); // update stock UpdateStockInventory(storeId, item.ToString(), "Add Inventory"); } //return cartItemId; } else { throw _exception.ThrowException(System.Net.HttpStatusCode.BadRequest, "", "Inventarielistan existerar inte."); } } return(list); }
public string AddOfflineCartItem(string userId, string cartId, string storeId, OfflineCartItemModel model) { return(_cartRepository.AddOfflineCartItem(userId, cartId, storeId, model)); }
public List <AddCartItemResponeseModel> AddCartItem(string userId, string cartId, string storeId, OfflineCartItemModel inventoryId) { return(_cartRepository.AddCartItem(userId, cartId, storeId, inventoryId)); }
public IHttpActionResult AddOfflineItemInCartList(string userId, string cartId, string storeId, OfflineCartItemModel model) { try { if (string.IsNullOrWhiteSpace(cartId) || string.IsNullOrWhiteSpace(storeId) || model.InventoryIds == null) { throw _exception.ThrowException(HttpStatusCode.BadRequest, "", "Ogiltig förfrågan."); } var message = _cartService.AddOfflineCartItem(userId, cartId, storeId, model); return(Ok(new { Message = message })); } catch (Exception ex) { _log.ErrorFormat("Error in open door. Error : {0}", ex.Message); _log.Error(ex); throw; } }
public IHttpActionResult AddItemInCart(string userId, string cartId, string storeId, OfflineCartItemModel inventoryId) { try { if (string.IsNullOrWhiteSpace(cartId) || inventoryId.InventoryIds.Length <= 0 || string.IsNullOrWhiteSpace(storeId)) { throw _exception.ThrowException(HttpStatusCode.BadRequest, "", "Ogiltig förfrågan."); } var cartItemList = _cartService.AddCartItem(userId, cartId, storeId, inventoryId); return(Ok(new { cartItems = cartItemList })); } catch (Exception ex) { _log.ErrorFormat("Error in open door. Error : {0}", ex.Message); _log.Error(ex); throw; } }