public Category EditCategory(Category categoryToUpdate) { categoryToUpdate.ModifiedOn = DateTime.Now; this.categoryRepo.Update(categoryToUpdate); this.categoryRepo.SaveChanges(); return categoryToUpdate; }
public Category Delete(Category categoryToDelete) { categoryToDelete.DeletedOn = DateTime.Now; categoryToDelete.IsDeleted = true; this.categoryRepo.AddDeleteFlag(categoryToDelete); this.categoryRepo.SaveChanges(); return categoryToDelete; }
public ActionResult AddCategory(AddCategoryViewModel model) { if (!this.ModelState.IsValid) { return View(model); } var imagesToDatabase = new List<CategoryImage>(); var categoryToDatabase = new List<Category>(); foreach (var item in model.Images) { var current = new CategoryImage { CategoryName = model.CategoryName, FileName = item.FileName, IsFrontImage = true, InputStream = item.InputStream, ContentLength = item.ContentLength, ContentType = item.ContentType }; imagesToDatabase.Add(current); } var categoryToAdd = new Category { Name = model.CategoryName, Description = model.CategoryDescription, FrontImageName = imagesToDatabase[0].FileName, Quantity = 0 }; categories.CreateCategory(categoryToAdd,imagesToDatabase); images.SaveImageFile(imagesToDatabase); images.SaveImageRecord(imagesToDatabase); return View("All"); }
public void CreateCategory(Category categoryToAdd,List<CategoryImage> images) { categoryToAdd.Images = images; this.categoryRepo.Add(categoryToAdd); this.categoryRepo.SaveChanges(); }