/// <summary>
        /// 保存修改信息
        /// </summary>
        /// <param name="model"></param>
        public void Edit(VmAdminCosmeticEdit model)
        {
            //向数据库插入数据
            var newModel = _context.Info.FirstOrDefault(m => m.CosmeticID == model.CosmeticID);

            // 将VmAdminCosmeticEdit类型的model变量里的内容复制到newModel
            Util.CopyObjectData(model, newModel, "CosmeticID");

            _context.SaveChanges();
        }
        public VmAdminCosmeticEdit GetEditModelById(System.Guid id)
        {
            //从数据库中取出相应数据
            var model = _context.Info.FirstOrDefault(m => m.CosmeticID == id);
            //填充相应ViewModel
            var newModel = new VmAdminCosmeticEdit();

            Util.CopyObjectData(model, newModel);
            return(newModel);
        }
 public ActionResult Edit(VmAdminCosmeticEdit model)
 {
     try
     {
         //输入校验
         if (!ModelState.IsValid)
         {
             return(View(model));
         }
         //向数据库插入数据
         _cosmeticService.Edit(model);
         //转向
         return(RedirectToAction("Detail", new { id = model.CosmeticID }));
     }
     catch (Exception ex)
     {
         ModelState.AddModelError("", ex.Message);
         return(View(model));
     }
 }