public ActionResult Edit(ItemCategory model) { model.OrganizationId = OrganizationId; model.CreatedDate = System.DateTime.Now; model.CreatedBy = UserID.ToString(); var repo = new ItemCategoryRepository(); bool isexists = repo.IsFieldExists(repo.ConnectionString(), "ItemCategory", "CategoryName", model.CategoryName, "itmCatId", model.itmCatId); if (!isexists) { var result = new ItemCategoryRepository().UpdateItemCategory(model); if (result.itmCatId > 0) { TempData["Success"] = "Updated Successfully! (" + result.itmCatRefNo + ")"; TempData["itmCatRefNo"] = result.itmCatRefNo; return(RedirectToAction("Create")); } else { TempData["error"] = "Some error occurred. Please try again."; return(View("Create", model)); } } else { TempData["error"] = "This material/spare category name already exists!"; TempData["itmCatRefNo"] = null; return(View("Create", model)); } }
public ActionResult Edit(int Id) { ViewBag.Title = "Edit"; ItemCategory objItemCategory = new ItemCategoryRepository().GetItemCategory(Id); return(View("Create", objItemCategory)); }
public ActionResult GetAll() { ItemCategoryRepository repository = new ItemCategoryRepository(); ModelState.Clear(); return(View(repository.GetAll())); }
// GET: ItemCategory/Edit/5 public ActionResult Edit(int id) { ItemCategoryRepository repository = new ItemCategoryRepository(); ItemCategoryModel model = repository.GetById(id); return(View(model)); }
public UnitOfWork(AroundContext context) { _context = context; _context.Database.EnsureCreated(); Items = new ItemRepository(_context); Favorites = new FavoriteRepository(_context); Users = new UserRepository(_context); Categories = new CategoryRepository(_context); ItemCategories = new ItemCategoryRepository(_context); }
// GET: Item/Edit/5 public ActionResult Edit(int id) { ItemRepository repository = new ItemRepository(); ItemCategoryRepository itemCategoryRep = new ItemCategoryRepository(); ItemModel model = repository.GetById(id); model.ItemCategories = itemCategoryRep.GetAll(); return(View(model)); }
// GET: Item/Create public ActionResult Create() { ItemCategoryRepository itemCategoryRep = new ItemCategoryRepository(); ItemModel model = new ItemModel { ItemCategories = itemCategoryRep.GetAll() }; return(View(model)); }
public List <WarframeItem> GetByCodexSection(CodexSection codexSection) { List <ItemCache> caches = new ItemCacheRepository(_unitOfWork).GetByCodexSection(codexSection); if (caches == null && !caches.Any() || caches.First().UpdatedTimestamp < DateTime.Now.AddDays(-2)) { List <ItemCategory> itemCategories = new ItemCategoryRepository(_unitOfWork).GetByCodexSection(codexSection); caches = RedownloadCache().Where(x => itemCategories.Select(y => y.ID).Contains(x.ItemCategoryID)).ToList(); } string test = "[" + string.Join(",", caches.Select(x => x.Data)) + "]"; return(JsonConvert.DeserializeObject <List <WarframeItem> >(test)); }
// GET: ItemCategory/Delete/5 public ActionResult Delete(int id) { try { ItemCategoryRepository repository = new ItemCategoryRepository(); repository.Delete(id); return(RedirectToAction("GetAll")); } catch { return(View()); } }
public ActionResult Edit(int id, ItemCategoryModel ModelObject) { try { ItemCategoryRepository repository = new ItemCategoryRepository(); repository.Update(ModelObject); return(RedirectToAction("GetAll")); } catch { return(View()); } }
public void TestInitialize() { context = new ApplicationDbContext(); itemRepository = new ItemRepository(context); itemcategoryService = new ItemCategoryService(context); itemcategoryRepository = new ItemCategoryRepository(context); //create new ItemCategory object and save into DB ItemCategory ic = itemcategoryRepository.Save(new ItemCategory() { ItemCategoryId = IdService.GetNewItemCategoryId(context), Name = "TEST", CreatedDateTime = DateTime.Now }); }
public ActionResult Delete(ItemCategory model) { var result = new ItemCategoryRepository().DeleteItemCategory(model); if (result.itmCatId > 0) { TempData["Success"] = "Deleted Successfully! (" + result.itmCatRefNo + ")"; return(RedirectToAction("Create")); } else { TempData["error"] = "Some error occurred. Please try again."; return(View("Create", model)); } }
public ActionResult Create(ItemCategoryModel ModelObject) { try { if (ModelState.IsValid) { ItemCategoryRepository repository = new ItemCategoryRepository(); repository.Add(ModelObject); return(RedirectToAction("GetAll")); } return(View()); } catch { return(View()); } }
public void SaveTestExistingChangeItemCategory() { // Arrange var itemCategory = new ItemCategoryRepository(context).FindById(1); var item = itemRepository.FindById("E030"); var original = item.ItemCategory; item.ItemCategory = itemCategory; // Act var result = itemRepository.Save(item); // Assert Assert.AreEqual(itemCategory, result.ItemCategory); // Tear Down item.ItemCategory = original; itemRepository.Save(item); }
public void TestInitialize() { context = new ApplicationDbContext(); itemCategoryService = new ItemCategoryService(context); itemCategoryRepository = new ItemCategoryRepository(context); }
public ItemCategoryService(ItemCategoryRepository ItemCategoryRepository, IUnitOfWork UnitOfWork) { this._ItemCategoryRepository = ItemCategoryRepository; this._UnitOfWork = UnitOfWork; }
public ItemCategoryService(ApplicationDbContext context) { this.context = context; itemCategoryRepository = new ItemCategoryRepository(context); statusRepository = new StatusRepository(context); }
public void TestInitialize() { // Arrange context = new ApplicationDbContext(); itemCategoryRepository = new ItemCategoryRepository(context); }
public ItemCategoryController() { _itemCategoryRepo = new ItemCategoryRepository(); }