public async Task <ActionResult> AddProduct(int id) { var userId = User.Identity.GetUserId(); var user = await _repository.User.Find(userId); var product = await _repository.Product.Find(id); BasketItem basketItem = await _repository.BasketItem.Find(b => b.ProductId == product.ProductId); if (basketItem != null) { basketItem.Amount++; } else { basketItem = new BasketItem { User = user, Product = product, Amount = 1 }; _repository.BasketItem.Add(basketItem); } await _repository.Commit(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Create([Bind(Include = "ProductId,Name,Description,Price")] Product product) { if (ModelState.IsValid) { _repository.Product.Add(product); await _repository.Commit(); return(RedirectToAction("Index")); } return(View(product)); }
public async Task <ActionResult> Create([Bind(Include = "CustomerId,FName,LName,Birthday,Discount")] Customer customer) { if (ModelState.IsValid) { _repository.Customer.Add(customer); await _repository.Commit(); return(RedirectToAction("Index")); } return(View(customer)); }
public async Task <ActionResult> Create([Bind(Include = "OrderId,OrderDate,CustomerId,Discount")] Order order) { if (ModelState.IsValid) { _repository.Order.Add(order); await _repository.Commit(); return(RedirectToAction("Index")); } ViewBag.CustomerId = new SelectList(await _repository.Customer.GetAll(), "CustomerId", "FName", order.CustomerId); return(View(order)); }
public async Task <ActionResult> Create([Bind(Include = "OrderId,Position,ProductId,Amount,Price,Discount")] OrderPosition orderPosition) { if (ModelState.IsValid) { _repository.OrderPosition.Add(orderPosition); await _repository.Commit(); return(RedirectToAction("Index")); } ViewBag.OrderId = new SelectList(await _repository.Order.GetAll(), "OrderId", "OrderId"); ViewBag.ProductId = new SelectList(await _repository.Product.GetAll(), "ProductId", "Name"); return(View(orderPosition)); }
/// <summary> /// Commit the stagged files. /// </summary> private void Commit() { CommitTreeElement root = commitTreeView.treeModel.root; List <string> fileList = new List <string>(); // Get all the checked files WindowHelper.GetElements(ref fileList, root); foreach (string file in fileList) { RepositoryManager.Stage(file); } SettingsTab settingsTab = editorWindow.GetSettingsTab(); RepositoryManager.Commit(settingsTab.GetUserUsername(), settingsTab.GetUserEmail(), currentCommitMessage); editorWindow.GetHistoryTab().RefreshHistory(); currentCommitMessage = ""; ReloadTree(); }
public async Task <ActionResult> Create([Bind(Include = "ProductId,ParentId,Content")] CommentView commentView) { if (ModelState.IsValid) { var comment = new Comment(); comment.ProductId = commentView.ProductId; comment.ParentId = commentView.ParentId; comment.Content = commentView.Content; comment.CreatedAt = DateTime.Now; comment.UserId = User.Identity.GetUserId(); _repository.Comment.Add(comment); await _repository.Commit(); return(RedirectToAction("Details", "Products", new { id = comment.ProductId })); } ViewData["ProductId"] = commentView.ProductId; ViewData["ParentId"] = commentView.ParentId; return(View(commentView)); }