Пример #1
0
        public ActionResult CreateSizeType(SizeTypeModel model)
        {
            if (ModelState.IsValid)
            {
                using (_dbContext = new karrykartEntities()) {
                    _dbContext.SizeTypes.Add(new SizeType()
                    {
                        Name = model.Name
                    });
                    _dbContext.SaveChanges();
                    _logger.WriteLog(CommonHelper.MessageType.Success, "Size type created successfully with Name=" + model.Name, "CreateUnit", "ProductSettingsController", User.Identity.Name);
                    Success("A new size type is created successfully.", true);
                    return(RedirectToAction("SizeTypeDetails", "ProductSettings"));
                }
            }

            return(View());
        }
Пример #2
0
        public ActionResult EditSizeType(SizeTypeModel model)
        {
            if (ModelState.IsValid)
            {
                using (_dbContext = new karrykartEntities())
                {
                    var sizetype = _dbContext.SizeTypes.Find(model.SizetypeID);
                    if (sizetype != null)
                    {
                        sizetype.Name = model.Name;
                        _dbContext.Entry(sizetype).State = System.Data.Entity.EntityState.Modified;
                        _dbContext.SaveChanges();
                        _logger.WriteLog(CommonHelper.MessageType.Success, "The sizetype has been edited successfully,sizetypeID = " + model.SizetypeID, "EditUnit", "ProductSettingsController", User.Identity.Name);
                        Success("The sizetype has been edited successfully.", true);
                        return(RedirectToAction("SizeTypeDetails", "ProductSettings"));
                    }
                }
            }

            return(View());
        }