public List <DirectorySubCategoryModel> GetDirectorySubCategoryList(int?CategoryId, int page, int pagesize) { var model = new List <DirectorySubCategoryModel>(); var collection = ent.tblDirectorySubCategories.Where(x => true); try { if (CategoryId != null) { collection = collection.Where(x => x.DirectorySubCategoryId == CategoryId).OrderBy(x => x.DirectorySubCategoryId).Skip((page - 1) * pagesize).Take(pagesize); } else { collection = collection.OrderBy(x => x.DirectorySubCategoryId).Skip((page - 1) * pagesize).Take(pagesize); } foreach (var item in collection) { var data = new DirectorySubCategoryModel() { DirectorySubCategoryId = item.DirectorySubCategoryId, DirectorySubCategoryName = item.DirectorySubCategoryName, DirectoryCategoryId = item.DirectoryCategoryId }; model.Add(data); } } catch (Exception ex) { } return(model); }
public ActionResult Edit(int id) { var model = new DirectorySubCategoryModel(); model = pro.GetDirectorySubCategoryData(id); return(View(model)); }
public ActionResult Edit(DirectorySubCategoryModel model) { if (ModelState.IsValid) { pro.Update(model); TempData["SuccessMessage"] = "Updated Successfully"; return(RedirectToAction("Index")); } return(View(model)); }
public ActionResult Create(DirectorySubCategoryModel model) { if (ModelState.IsValid) { pro.Insert(model); TempData["SuccessMessage"] = "Saved Successfully"; return(RedirectToAction("Index", "DirectorySubCategory")); } return(View(model)); }
public ActionResult Index(int page = 1) { int pagesize = 100; var model = new DirectorySubCategoryModel(); model.DirectorySubCategoryModelList = pro.GetDirectorySubCategoryList(page, pagesize); ViewBag.currentPage = page; ViewBag.TotalPages = Math.Ceiling((double)pro.GetTotalItemCount() / pagesize); return(View(model)); }
public void Insert(DirectorySubCategoryModel model) { try { var objToSave = new tblDirectorySubCategory() { DirectorySubCategoryId = model.DirectorySubCategoryId, DirectorySubCategoryName = model.DirectorySubCategoryName, DirectoryCategoryId = model.DirectoryCategoryId }; //objToSave.CreatedBy = Utility.GetCurrentLoginUser(); objToSave.CreatedDate = DateTime.Now.ToShortDateString().ToString(); ent.tblDirectorySubCategories.Add(objToSave); ent.SaveChanges(); } catch (Exception ex) { } }
public DirectorySubCategoryModel GetDirectorySubCategoryData(int DirectorySubCategoryId) { var model = new DirectorySubCategoryModel(); try { var item = ent.tblDirectorySubCategories.Single(x => x.DirectorySubCategoryId == DirectorySubCategoryId); model = new DirectorySubCategoryModel() { DirectorySubCategoryId = item.DirectorySubCategoryId, DirectorySubCategoryName = item.DirectorySubCategoryName, DirectoryCategoryId = item.DirectoryCategoryId }; } catch (Exception ex) { } return(model); }
public void Update(DirectorySubCategoryModel model) { try { var objToEdit = ent.tblDirectorySubCategories.Single(x => x.DirectorySubCategoryId == model.DirectorySubCategoryId); objToEdit.DirectorySubCategoryId = model.DirectorySubCategoryId; objToEdit.DirectorySubCategoryName = model.DirectorySubCategoryName; objToEdit.DirectoryCategoryId = model.DirectoryCategoryId; //objToEdit.UpdatedBy = Utility.GetCurrentLoginUser(); //objToEdit.UpdateDate = DateTime.Now.ToShortDateString().ToString(); ent.Entry(objToEdit).State = System.Data.Entity.EntityState.Modified; ent.SaveChanges(); } catch (Exception ex) { //Log.Error(string.Format("Error! on Update InventoryItemCategoryData Data Auction with error message: {0}", // ex.Message)); //Log.Error(string.Format("Error with exception: {0}", ex.StackTrace)); } }
public ActionResult Create() { var model = new DirectorySubCategoryModel(); return(View(model)); }