public List <SelectListItem> GetGeneralCategories()
        {
            var generalCategoryDropDownList = new List <SelectListItem>();

            generalCategoryDropDownList.Insert(0, new SelectListItem()
            {
                Text = "Select generalCategory", Value = string.Empty
            });

            try
            {
                var generalCategoryList = _generalCategoryManager.GetAll(c => true);

                foreach (var generalCategory in generalCategoryList)
                {
                    var item = new SelectListItem()
                    {
                        Text = generalCategory.Name, Value = generalCategory.Id.ToString()
                    };
                    generalCategoryDropDownList.Add(item);
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
            }

            return(generalCategoryDropDownList);
        }
Exemplo n.º 2
0
        // Json Result GetAllGeneralCategory
        public JsonResult GetAllGeneralCategory()
        {
            var totalRecord = generalCategoryManager.GetAll().Count;


            var generalcategorylist = generalCategoryManager.GetAll();

            //.OrderBy(sortColumn + " " + sortColumnDir)
            var gcategories = generalcategorylist.Select(c => new
            {
                c.Id,
                c.Name,
                c.Code
            });


            return(Json(new{ data = gcategories }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult Entry()
        {
            if (Session["username"] == null)
            {
                return(RedirectToAction("HomePage", "Home"));
            }

            ViewBag.orglist = generalCategoryManager.GetAll();

            ViewBag.assetlist = assetManager.GetSome(5);
            bool s = Request.QueryString["success"] == "true";

            if (s)
            {
                ViewData["success"] = "Save Successfully";
            }

            return(View());
        }
        public ActionResult Create()
        {
            if (Session["username"] == null)
            {
                return(RedirectToAction("HomePage", "Home"));
            }

            var productcategorylist = productCategoryManager.GetSome(5);

            ViewBag.plist = productcategorylist.ToList();

            var list = generalCategoryManager.GetAll();

            ViewBag.orglist = list.ToList();
            bool s = Request.QueryString["success"] == "true";

            if (s)
            {
                ViewData["success"] = "Save Successfully";
            }
            return(View());
        }
        public ActionResult Create(GeneralCategory generalCategory)
        {
            //PartialMenuView();
            if (ModelState.IsValid && generalCategory != null)
            {
                ModelState.Clear();

                try
                {
                    if (_generalCategoryManager.Add(generalCategory))
                    {
                        ViewBag.Msg = "Created successfully!";
                        return(View());
                    }
                }
                catch (Exception exception)
                {
                    int NameExist = _generalCategoryManager.GetAll(c => c.Name.Equals(generalCategory.Name)).Count();

                    if (NameExist > 0)
                    {
                        generalCategory.Name = null;
                        ModelState.AddModelError("Name", "General Category name already exists");
                    }

                    int ShortNameExits = _generalCategoryManager.GetAll(c => c.ShortName == generalCategory.ShortName).Count();

                    if (ShortNameExits > 0)
                    {
                        generalCategory.ShortName = null;
                        ModelState.AddModelError("ShortName", "Short name already exists");
                    }
                }
            }

            return(View(generalCategory));
        }
 // GET: GeneralCategory
 public ActionResult Index()
 {
     return(View(_generalCategoryManager.GetAll()));
 }