public int UpdateUserOption(string ProcessorSku, string MainboarSku, int UserId) { UserCartModel userCart = new UserCartModel(); int rowAffected = userCart.UpdateUserOption(ProcessorSku, MainboarSku, UserId); return(rowAffected); }
public async Task <IActionResult> Post([FromBody] UserCartModel userCartModel) { if (ModelState.IsValid) { await _userCartService.AddUserCart(userCartModel); return(Ok(userCartModel)); } return(BadRequest(ModelState)); }
public IHttpActionResult ConfirmToOrder(UserCartModel cartModel) { Order order = Manager.ConfirmCartToOrder(cartModel.UserId, cartModel.CartId); if (order == null) { return(NotFound()); } return(Ok(order)); }
public IHttpActionResult Confirm(UserCartModel userCart) { Order order = Manager.ConfirmCart(userCart.UserId, userCart.CartId); if (order == null) { return(NotFound()); } return(Ok(order)); }
public List <UserCartModel> GetCartProductList(List <int> products) { try { string productIDs = string.Join(", ", products); DBConnect db = new DBConnect(); SqlCommand cmd = new SqlCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "SELECT * FROM Products WHERE ProductID in (" + productIDs + ")"; DataTable tbl = db.GetData(cmd); List <UserCartModel> userCartModels = new List <UserCartModel>(); if (tbl != null) { foreach (DataRow row in tbl.Rows) { UserCartModel userCartModel = new UserCartModel(); ProductModel product = new ProductModel(); product.productId = Convert.ToInt32(row[0].ToString()); product.productName = row[1].ToString(); product.description = row[2].ToString(); product.price = Convert.ToDecimal(row[3].ToString()); product.imagePath = row[4].ToString(); userCartModel.product = product; userCartModel.quantity = products.Count(x => x == product.productId); userCartModel.productTotalPrice = userCartModel.product.price * userCartModel.quantity; userCartModels.Add(userCartModel); } } return(userCartModels); } catch (Exception e) { return(null); } }
public int CheckProductIsExist(int UserId, string SKU) { UserCartModel userCart = new UserCartModel(); return(userCart.CheckProductIsExist(UserId, SKU)); }
public int CheckUserChooseOrNot(int UserId) { UserCartModel userCart = new UserCartModel(); return(userCart.CheckUserChooseOrNot(UserId)); }
public async Task Edit(UserCartModel bookCartModel) { var sageCartEntities = Mapper.Map <UserCartModel, UserCart>(bookCartModel); _context.Entry(sageCartEntities).State = EntityState.Modified; }
public async Task Create(UserCartModel sageCartModel) { var sageCartEntities = Mapper.Map <UserCartModel, UserCart>(sageCartModel); await _context.UserCart.AddAsync(sageCartEntities); }
public async Task <IActionResult> Delete([FromBody] UserCartModel id) { await _userCartService.DeleteUserCart(id); return(Ok()); }
public async Task EditUserCart(UserCartModel sageCartModel) { await _unitOfWork.UserCartRepository.Edit(sageCartModel); await _unitOfWork.SaveChanges(); }
public async Task AddUserCart(UserCartModel sageCartModel) { await _unitOfWork.UserCartRepository.Create(sageCartModel); await _unitOfWork.SaveChanges(); }