Example #1
0
        //
        // GET: /StockSubCategory/

        public ActionResult Index()
        {
            StockSubCategoryModel model = new StockSubCategoryModel();

            model.StockSubCategoryList = pro.GetList();
            return(View(model));
        }
Example #2
0
 public ActionResult Create(StockSubCategoryModel model)
 {
     try
     {
         int i = pro.Insert(model);
         if (i != 0)
         {
             TempData["success"] = UtilityMessage.save;
         }
         else
         {
             TempData["success"] = UtilityMessage.savefailed;
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         TempData["success"] = UtilityMessage.savefailed;
         return(RedirectToAction("Index"));
     }
 }
        public int Insert(StockSubCategoryModel model)
        {
            EHMSEntities ent = new EHMSEntities();

            var item = ent.SetupStockSubCategories.Where(x => x.StockSubCategoryName == model.StockSubCategoryName);

            if (item.Count() == 0)
            {
                var objToSave = AutoMapper.Mapper.Map <StockSubCategoryModel, SetupStockSubCategory>(model);
                objToSave.CreatedBy   = 0;
                objToSave.CreatedDate = DateTime.Now;
                objToSave.Status      = true;
                ent.SetupStockSubCategories.Add(objToSave);
                int i = ent.SaveChanges();
                return(i);
            }
            else
            {
                return(0);
            }
        }
Example #4
0
 public ActionResult Edit(StockSubCategoryModel model)
 {
     try
     {
         // TODO: Add update logic here
         int i = pro.Update(model);
         if (i != 0)
         {
             TempData["success"] = UtilityMessage.edit;
         }
         else
         {
             TempData["success"] = UtilityMessage.editfailed;
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         TempData["success"] = UtilityMessage.editfailed;
         return(RedirectToAction("Index"));
     }
 }
        public int Update(StockSubCategoryModel model)
        {
            EHMSEntities ent = new EHMSEntities();

            var item = ent.SetupStockSubCategories.Where(x => x.StockSubCategoryName == model.StockSubCategoryName && x.StockSubCategoryID != model.StockSubCategoryID);

            if (item.Count() == 0)
            {
                var objToEdit = ent.SetupStockSubCategories.Where(x => x.StockSubCategoryID == model.StockSubCategoryID).FirstOrDefault();
                model.CreatedBy   = objToEdit.CreatedBy;
                model.CreatedDate = objToEdit.CreatedDate;
                model.Status      = objToEdit.Status;
                AutoMapper.Mapper.Map(model, objToEdit);
                ent.Entry(objToEdit).State = System.Data.EntityState.Modified;
                int i = ent.SaveChanges();
                return(i);
            }
            else
            {
                return(0);
            }
        }
Example #6
0
        // GET: /StockSubCategory/Edit/5

        public ActionResult Edit(int id)
        {
            StockSubCategoryModel model = pro.GetList().Where(x => x.StockSubCategoryID == id).FirstOrDefault();

            return(View(model));
        }