public IHttpActionResult Post(Tbl_Category category) { //adminLoginRepository.Insert(Admin); categoryrepository.Insert(category); return(Created("api/categorys/" + category.CategoryId, category)); }
public ActionResult UpdateCategory(CategoryDetail cd) { if (ModelState.IsValid) { Tbl_Category cat = _unitOfWork.GetRepositoryInstance <Tbl_Category>().GetFirstOrDefault(cd.CategoryId); cat = cat != null ? cat : new Tbl_Category(); cat.CategoryName = cd.CategoryName; if (cd.CategoryId != 0) { _unitOfWork.GetRepositoryInstance <Tbl_Category>().Update(cat); _unitOfWork.SaveChanges(); } else { cat.IsActive = true; cat.IsDelete = false; _unitOfWork.GetRepositoryInstance <Tbl_Category>().Add(cat); } return(RedirectToAction("Categories")); } else { return(View("UpdateCategory", cd)); } }
public ActionResult AddCategory(Tbl_Category new_c) { _unitOfWork.GetRepositoryInstance <Tbl_Category>().Add(new_c); //dbMyOnlineShoppingEntities db = new dbMyOnlineShoppingEntities(); //db.func_insert_category(new_c.CategoryName, new_c.IsActive, new_c.IsDelete); return(RedirectToAction("Categories")); }
public ActionResult Delete(int?id, Tbl_Category category) { Tbl_Category cate = new Tbl_Category(); try { if (ModelState.IsValid) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } cate = db.Tbl_Category.Find(id); if (cate == null) { return(HttpNotFound()); } db.Tbl_Category.Remove(cate); db.SaveChanges(); } //return View(cate); return(RedirectToAction("Index")); // TODO: Add delete logic here } catch { return(View()); } }
public ActionResult UpdateCategory(Tbl_Category category) { if (Session["AdminId"] != null) { category.IsActive = true; category.IsDelete = false; var name = _DBEntity.Tbl_Category.Where(a => a.CategoryName == category.CategoryName).ToList(); if (name.Count() >= 1) { ViewBag.Message = " sorry , this Category is allready taken"; return(View()); } else { _DBEntity.Tbl_Category.Add(category); _DBEntity.SaveChanges(); return(RedirectToAction("Categories")); } } else { return(RedirectToAction("Login", "Account")); } //_unitOfWork.GetRepositoryInstance<Tbl_Category>().Add(category); }
public ActionResult CategoryEdit(Tbl_Category table) { using (GenericUnitOfWork _unitOfWork = new GenericUnitOfWork()) { _unitOfWork.GetRepositoryInstance <Tbl_Category>().Update(table); return(RedirectToAction("Categories")); } }
public ActionResult DeleteConfirmed(int id) { Tbl_Category tbl_Category = db.Tbl_Category.Find(id); db.Tbl_Category.Remove(tbl_Category); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult CategoryDelete(int categoryId) { Tbl_Category det = unit.GetRepositoryInstance <Tbl_Category>().GetFirstorDefault(categoryId); det.IsDelete = true; unit.GetRepositoryInstance <Tbl_Category>().Update(det); return(RedirectToAction("Categories")); }
// [ValidateAntiForgeryToken] // [Authorize(Roles = "Admin")] public ActionResult DeleteConfirmed(int id) { Tbl_Category employee = db.Tbl_Category.Find(id); db.Tbl_Category.Remove(employee); db.SaveChanges(); return(RedirectToAction("Categories_List")); }
public void Tbl_Category_CompareTwoAsserts_AreEqual() { var actual = new Tbl_Category { Cat_ID = 1, Cat_Name = "C#" }; Assert.AreEqual(1, actual.Cat_ID); Assert.AreEqual("C#", actual.Cat_Name); }
public ActionResult CategoryAdd(Tbl_Category tbl, HttpPostedFileBase file) { if (ModelState.IsValid) { _unitOfWork.GetRepositoryInstance <Tbl_Category>().Add(tbl); return(RedirectToAction("Categories")); } return(View(tbl)); }
public ActionResult Edit([Bind(Include = "Ca_ID,Ca_Name")] Tbl_Category tbl_Category) { if (ModelState.IsValid) { db.Entry(tbl_Category).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tbl_Category)); }
public ActionResult UpdateCategory([Bind(Include = "CategoryId,CategoryName,IsActive,IsDelete")] Tbl_Category _cat) { if (ModelState.IsValid) { db.Entry(_cat).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Categories_List")); } return(View(_cat)); }
public ActionResult AddCategory([Bind(Include = "CategoryId,CategoryName,IsActive,IsDelete")] Tbl_Category _cat) { if (ModelState.IsValid) { db.Tbl_Category.Add(_cat); db.SaveChanges(); return(RedirectToAction("Categories_List")); } return(View(_cat)); }
public ActionResult DeleteConfirmed(int id) { Tbl_Category tbl_Category = db.Categories.Find(id); tbl_Category.IsActive = false; tbl_Category.IsDelete = true; tbl_Category.SalesmanUserId = User.Identity.GetUserId(); db.Categories.AddOrUpdate(tbl_Category); db.SaveChanges(); return(RedirectToAction("Index")); }
public void AddCategories(CategoryDetail category) { using (dbMyOnlineShoppingEntities db = new dbMyOnlineShoppingEntities()) { Tbl_Category CA = new Tbl_Category(); CA.CategoryName = category.CategoryName; db.Tbl_Category.Add(CA); db.SaveChanges(); } }
public ActionResult Create([Bind(Include = "Ca_ID,Ca_Name")] Tbl_Category tbl_Category) { if (ModelState.IsValid) { db.Tbl_Category.Add(tbl_Category); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tbl_Category)); }
private static string GetEnumValue(Tbl_Category category) { try { return(Enum.Parse(typeof(Types), category.Type.ToString()).ToString()); } catch (Exception) { return(string.Empty); } }
public ActionResult CategoryEdit(Tbl_Category category) { if (Session["AdminId"] != null) { _unitOfWork.GetRepositoryInstance <Tbl_Category>().Update(category); return(RedirectToAction("Categories")); } else { return(RedirectToAction("Login", "Account")); } }
public IActionResult CreateCategory(CategoryDetail model) { if (ModelState.IsValid) { Tbl_Category category = new Tbl_Category(); category.CategoryName = model.CategoryName; category.IsActive = model.IsActive; category.IsDelete = model.IsDelete; cat_repository.Insert(category); return(RedirectToAction("AllCategories")); } return(View(model)); }
public ActionResult Edit([Bind(Include = "CategoryId,CategoryName,IsActive,IsDelete")] Tbl_Category tbl_Category) { if (ModelState.IsValid) { tbl_Category.IsActive = true; tbl_Category.IsDelete = false; tbl_Category.SalesmanUserId = User.Identity.GetUserId(); db.Entry(tbl_Category).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tbl_Category)); }
public ActionResult UpdateCategory([Bind(Include = "CategoryId,CategoryName")] Tbl_Category c) { Tbl_Category c_new = new Tbl_Category(); c_new = _unitOfWork.GetRepositoryInstance <Tbl_Category>().GetFirstorDefault(c.CategoryId); c_new.CategoryName = c.CategoryName; _unitOfWork.GetRepositoryInstance <Tbl_Category>().Update(c_new); return(RedirectToAction("Categories")); }
public static Category MapFrom(this Tbl_Category category) { return(new Category { Id = category.Id, Name = category.Name, Color = category.Color, Type = category.Type, TypeName = GetEnumValue(category), Enabled = category.Enabled, Created_At = category.Created_At, Updated_At = category.Updated_At, }); }
// GET: Category/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Tbl_Category tbl_Category = db.Tbl_Category.Find(id); if (tbl_Category == null) { return(HttpNotFound()); } return(View(tbl_Category)); }
// GET: Category/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Tbl_Category cat = db.Tbl_Category.Find(id); if (cat == null) { return(HttpNotFound()); } return(View(cat)); }
public ActionResult AddCategory(Tbl_Category catID) { //Tbl_Category cat; unit.GetRepositoryInstance <Tbl_Category>().Add(catID); //if (catID != null) //{ // cat = JsonConvert.DeserializeObject<CategoryDetails>(JsonConvert.SerializeObject(unit.GetRepositoryInstance<Tbl_Category>().GetFirstorDefault(catID))); //} //else // cat = new Tbl_Category(); return(RedirectToAction("Categories")); }
// GET: Category/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Tbl_Category cat = db.Tbl_Category.Find(id); db.Tbl_Category.Remove(cat); db.SaveChanges(); if (cat == null) { return(HttpNotFound()); } return(RedirectToAction("Index")); }
public ActionResult UpdateCategory(int categoryId) { //CategoryDetail cd; //if (categoryId != null) //{ // string json = JsonConvert.SerializeObject(_unitOfWork.GetRepositoryInstance<Tbl_Category>().GetFirstorDefault(categoryId)); // cd = JsonConvert.DeserializeObject<CategoryDetail>(json); //} //else //{ // cd = new CategoryDetail(); //} Tbl_Category cd = _unitOfWork.GetRepositoryInstance <Tbl_Category>().GetFirstorDefault(categoryId); return(View(cd)); }
public ActionResult AddCategory(Tbl_Category cat) { List <Tbl_Category> li = db.Tbl_Category.OrderByDescending(x => x.Cat_ID).ToList(); ViewData["List"] = li; Random r = new Random(); Tbl_Category c = new Tbl_Category(); c.Cat_Name = cat.Cat_Name; c.cat_encrypted = crypto.Encrypt(cat.Cat_Name.Trim() + r.Next().ToString(), true); c.Cat_FK_adid = Convert.ToInt32(Session["Ad_ID"].ToString()); db.Tbl_Category.Add(c); db.SaveChanges(); return(RedirectToAction("AddCategory")); }
public ActionResult Create(Tbl_Category category) { try { if (ModelState.IsValid) { category.CreatedDate = DateTime.Now; db.Tbl_Category.Add(category); db.SaveChanges(); return(RedirectToAction("Index")); } // TODO: Add insert logic here return(View(category)); } catch { return(View()); } }