public List<Category> getResult(int? id, string sc) { var cat = new Category() { ID = 1, name = "Rusbrus" }; List<Category> catlist = new List<Category>(); catlist.Add(cat); return catlist; }
public List<Category> getAll(int? id) { var cat1 = new Category() { ID = 1, name = "Rusbrus" }; var cat2 = new Category() { ID = 2, name = "Brennevin" }; var cat3 = new Category() { ID = 3, name = "Tilfeldig navn" }; var cat4 = new Category() { ID = 4, name = "Brus" }; var cat5 = new Category() { ID = 5, name = "Melk" }; List<Category> catlist = new List<Category>(); catlist.Add(cat1); catlist.Add(cat2); catlist.Add(cat3); catlist.Add(cat4); catlist.Add(cat5); if (id == null) return catlist; else return catlist.Where(c => c.ID == id).ToList(); }
public bool updateCategory(int id, Category c, int adminid) { return _category.updateCategory(id, c, adminid); }
public bool Add(Category category, int adminId) { return _category.Add(category, adminId); }
public bool updateCategory(int id, Category c, int adminid) { if (id == 0 || c == null) return false; return true; }
public bool Add(Category category, int id) { if (id == 0 ) return false; return true; }
public ActionResult updateCatergoryDetails(CategoryInfo c) { if (!isAdmin()) return RedirectToAction("LogIn", "Main"); if (ModelState.IsValid) { Customer a = (Customer)Session["loggedInUser"]; Category cat = new Category(); cat.ID = c.id; cat.name = c.name; var b = _categoryBLL.updateCategory(c.id, cat ,a.id); if (b) return Json(new { success = true, message = "Kategorien ble endret", redirect = "/Category/ListCategories" }); return Json(new { success = false, message = "Noe gikk galt, prøv igjen senere" }); } return Json(new { success = false, message = "Feil i validering" }); }
public ActionResult newCategory(CategoryInfo category) { if (!isAdmin()) return RedirectToAction("LogIn", "Main"); if (ModelState.IsValid) { Customer c = (Customer)Session["loggedInUser"]; Category cat = new Category(); cat.ID = category.id; cat.name = category.name; bool OK = _categoryBLL.Add(cat, c.id); if (OK) return Json(new { success = true, message = cat.name + " ble lagt til.", redirect = "/Category/ListCategories?item_desc" }); return Json(new { success = false, message = "noe gikk galt, prøv igjen senere." }); } return Json(new { success = false, message = "Feil i validering" }); }
public bool Add(Category category, int adminId) { var newCategory = new Categories() { Name = category.name }; try { var db = new DatabaseContext(); db.Categories.Add(newCategory); db.SaveChanges(adminId); return true; } catch (Exception failed) { writeToFile(failed); return false; } }
public bool updateCategory(int id, Category c, int adminid) { var db = new DatabaseContext(); try { Categories cat = db.Categories.FirstOrDefault(ca => ca.Id == id); cat.Name = c.name; db.SaveChanges(adminid); return true; } catch(Exception e) { writeToFile(e); return false; } }