public IActionResult OnGetCreate() { var create = new InventoryCreate { Products = _productApplication.GetProducts() }; return(Partial("./Create", create)); }
public ActionResult Create(int id) { var model = new InventoryCreate { CharacterId = id, OwnerId = GetGuid() }; return(View(model)); }
public InventoryCreate GetInventoryCreateModel(int id) { var list = GetStoreInventories(id); var model = new InventoryCreate() { StoreInventory = list, StoreId = id, InventoryCount = list.Count(), }; return(model); }
public bool CreateInventory(int id, InventoryCreate model) { var entity = new Inventory() { StoreId = id, ProductId = model.ProductId, Quantity = model.Quantity }; using (var ctx = new ApplicationDbContext()) { ctx.Inventories.Add(entity); return(ctx.SaveChanges() == 1); } }
public OperationResult Create(InventoryCreate create) { var operation = new OperationResult(); if (_inventoryRepository.Exists(i => i.ProductId == create.ProductId)) { return(operation.Fail(ApplicationMessages.DuplicateRecord)); } var inventory = new Inventory(create.ProductId, create.UnitPrice); _inventoryRepository.Create(inventory); _inventoryRepository.SaveChanges(); return(operation.Success()); }
public bool CreateInventory(InventoryCreate model) { var entity = new Inventory() { ItemName = model.ItemName, SkuNumber = model.SkuNumber, ItemDescription = model.ItemDescription, ItemPrice = model.ItemPrice, TypeOfItem = model.TypeOfItem }; using (var ctx = new ApplicationDbContext()) { ctx.Inventory.Add(entity); return(ctx.SaveChanges() == 1); } }
public bool CreateInventory(InventoryCreate model) { var entity = new Inventory() { OwnerId = _userId, Liquor = model.InventoryLiquor, Fruit = model.InventoryFruit, Juice = model.InventoryJuice, Other = model.InventoryOther }; using (var ctx = new ApplicationDbContext()) { ctx.Inventory.Add(entity); return(ctx.SaveChanges() == 1); } }
public bool InventoryItemCreate(InventoryCreate item) { var entity = new Inventory { OwnerId = _ownerId, InventoryId = item.InventoryId, CharacterId = item.CharacterId, ItemName = item.ItemName, ItemQuantity = item.ItemQuantity, ItemType = item.ItemType }; using (var ctx = new ApplicationDbContext()) { ctx.Inventories.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult Create(InventoryCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateInventoryService(); if (service.CreateInventory(model)) { TempData["SaveResult"] = "The input was added to the inventory."; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Inventory could not be saved."); return(View(model)); }
public ActionResult Create(InventoryCreate item) { if (!ModelState.IsValid) { return(View(item)); } var service = CreateInventoryService(item); if (service.InventoryItemCreate(item)) { TempData["SaveResult"] = "Your item was created."; return(RedirectToAction("Index", new { id = item.CharacterId })); } ModelState.AddModelError("", "Item was not created."); return(View(item)); }
public ActionResult Create(int id, InventoryCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateInventoryService(); if (service.CreateInventory(id, model)) { TempData["SaveResult"] = "Products were added to your inventory."; return(RedirectToAction("Index")); } ; ModelState.AddModelError("", "Product could not be added."); ViewBag.ProductId = new SelectList(service.Products(), "ProductId", "Name"); return(View(model)); }
public ActionResult Create(InventoryCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateInventoryService(); if (service.CreateInventory(model)) { TempData["SaveResult"] = "Your inventory item was created successfully"; return(RedirectToAction("Index")); } ; //return View(model); ModelState.AddModelError("", "Inventory could not be created."); return(View(model)); }
private InventoryService CreateInventoryService(InventoryCreate item) { var service = new InventoryService(GetGuid(), item.CharacterId); return(service); }
public JsonResult OnPostCreate(InventoryCreate create) { var result = _inventoryApplication.Create(create); return(new JsonResult(result)); }