Exemplo n.º 1
0
        public List <DirectoryCategoryModel> GetDirectoryCategoryList(int?CategoryId, int page, int pagesize)
        {
            var model      = new List <DirectoryCategoryModel>();
            var collection = ent.tblDirectoryCategories.Where(x => true);

            try
            {
                if (CategoryId != null)
                {
                    collection = collection.Where(x => x.DirectoryCategoryId == CategoryId).OrderBy(x => x.DirectoryCategoryId).Skip((page - 1) * pagesize).Take(pagesize);
                }
                else
                {
                    collection = collection.OrderBy(x => x.DirectoryCategoryId).Skip((page - 1) * pagesize).Take(pagesize);
                }
                foreach (var item in collection)
                {
                    var data = new DirectoryCategoryModel()
                    {
                        DirectoryCategoryId   = item.DirectoryCategoryId,
                        DirectoryCategoryName = item.DirectoryCategoryName,
                    };
                    model.Add(data);
                }
            }
            catch (Exception ex)
            {
            }

            return(model);
        }
        public ActionResult Edit(int id)
        {
            var model = new DirectoryCategoryModel();

            model = pro.GetDirectoryCategoryData(id);

            return(View(model));
        }
 public ActionResult Edit(DirectoryCategoryModel model)
 {
     if (ModelState.IsValid)
     {
         pro.Update(model);
         TempData["SuccessMessage"] = "Updated Successfully";
         return(RedirectToAction("Index"));
     }
     return(View(model));
 }
 public ActionResult Create(DirectoryCategoryModel model)
 {
     if (ModelState.IsValid)
     {
         pro.Insert(model);
         TempData["SuccessMessage"] = "Saved Successfully";
         return(RedirectToAction("Index", "DirectoryCategory"));
     }
     return(View(model));
 }
        public ActionResult Index(int page = 1)
        {
            int pagesize = 100;
            var model    = new DirectoryCategoryModel();

            model.DirectoryCategoryModelList = pro.GetDirectoryCategoryList(page, pagesize);
            ViewBag.currentPage = page;
            ViewBag.TotalPages  = Math.Ceiling((double)pro.GetTotalItemCount() / pagesize);
            return(View(model));
        }
Exemplo n.º 6
0
 public void Insert(DirectoryCategoryModel model)
 {
     try
     {
         var objToSave = new tblDirectoryCategory()
         {
             DirectoryCategoryId   = model.DirectoryCategoryId,
             DirectoryCategoryName = model.DirectoryCategoryName,
         };
         //objToSave.CreatedBy = Utility.GetCurrentLoginUser();
         objToSave.CreatedDate = DateTime.Now.ToShortDateString().ToString();
         ent.tblDirectoryCategories.Add(objToSave);
         ent.SaveChanges();
     }
     catch (Exception ex)
     {
     }
 }
Exemplo n.º 7
0
        public DirectoryCategoryModel GetDirectoryCategoryData(int DirectoryCategoryId)
        {
            var model = new DirectoryCategoryModel();

            try
            {
                var item = ent.tblDirectoryCategories.Single(x => x.DirectoryCategoryId == DirectoryCategoryId);
                model = new DirectoryCategoryModel()
                {
                    DirectoryCategoryId   = item.DirectoryCategoryId,
                    DirectoryCategoryName = item.DirectoryCategoryName,
                };
            }
            catch (Exception ex)
            {
            }


            return(model);
        }
Exemplo n.º 8
0
        public void Update(DirectoryCategoryModel model)
        {
            try
            {
                var objToEdit = ent.tblDirectoryCategories.Single(x => x.DirectoryCategoryId == model.DirectoryCategoryId);
                objToEdit.DirectoryCategoryId   = model.DirectoryCategoryId;
                objToEdit.DirectoryCategoryName = model.DirectoryCategoryName;

                //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 DirectoryCategoryModel();

            return(View(model));
        }