Ejemplo n.º 1
0
        /// <summary>
        /// To Edit database
        /// </summary>
        /// <param name="SubCategoryBOobj"></param>
        /// <returns></returns>
        public string Edit(SubCategoryBO SubCategoryBOobj)
        {
            SubCategoryDAL SubCategoryDALobj = new SubCategoryDAL(); //Data pass -to Database Layer

            try
            {
                return(SubCategoryDALobj.Edit(SubCategoryBOobj));
            }
            catch
            {
                throw;
            }
            finally
            {
                SubCategoryDALobj = null;
            }
        }
Ejemplo n.º 2
0
        public ActionResult Edit(SubCategoryViewModel model)
        {
            SubCategory subcategory = new SubCategory();

            if (ModelState.IsValid)
            {
                subcategory.SubCategoryId         = model.SubCategoryId;
                subcategory.SubCategoryName       = model.SubcategoryName;
                subcategory.category.CategoryId   = model.CategoryId;
                subcategory.category.CategoryName = model.CategoryName;
                subcategory.PackedQuantity        = model.PackedQuantity;
                subcategory.code       = model.Code;
                subcategory.Rate       = Convert.ToDecimal(model.Rate);
                subcategory.ModifiedBy = "Admin";
                subcategory.ModifiedOn = DateTime.Now;

                subCategoryDAL.Edit(subcategory);
                TempData["SuccessMsg"] = "Sub Category Updated Successfully";
                return(RedirectToAction("Index"));
            }

            subcategory = new SubCategory();

            subcategory = subCategoryDAL.ReadSubCategoryDetailsById(model.SubCategoryId);

            model.CategoryId      = subcategory.category.CategoryId;
            model.CategoryName    = subcategory.category.CategoryName;
            model.SubCategoryId   = subcategory.SubCategoryId;
            model.SubcategoryName = subcategory.SubCategoryName;
            model.PackedQuantity  = subcategory.PackedQuantity;
            model.Code            = subcategory.code;
            model.Rate            = subcategory.Rate;


            var lstCategory = categoryDAL.ReadAllCategory();

            model.lstCategory = new List <CategoryViewModel>();
            model.lstCategory = lstCategory.ConvertAll(x => new CategoryViewModel
            {
                CategoryId   = x.CategoryId,
                CategoryName = x.CategoryName
            });


            var lst = subCategoryDAL.ReadAllSubCategory();

            model.lstSubCategories = new List <SubCategoryViewModel>();
            model.lstSubCategories = lst.ConvertAll(x => new SubCategoryViewModel
            {
                SubCategoryId   = x.SubCategoryId,
                SubcategoryName = x.SubCategoryName,
                PackedQuantity  = x.PackedQuantity,
                Code            = x.code,
                Rate            = x.Rate,
                CategoryId      = x.category.CategoryId,
                CategoryName    = x.category.CategoryName
            });

            model.IsEdit = true;

            return(View("Index", model));
        }