public ActionResult _EditModelImage(ModelImageEditVM mModelImageVm)
        {
            var mdl = _svc.GetModel(mModelImageVm.ModelId);

            if (string.IsNullOrEmpty(mModelImageVm.FilePath))
            {
                if (mdl.Image != null)
                {
                    _svc.DeleteImage((int)mdl.ImageId);
                    mdl.ImageId = null;
                }
            }
            else
            {
                if (mdl.Image == null)
                {
                    mdl.Image = new ModelImage();
                }
                UpdateModel(mdl.Image);
                mdl.Image.LoadFile(mModelImageVm.FilePath);
                DocumentController.RemoveFile(mModelImageVm.FilePath);
            }

            if (ExecuteRepositoryAction(() => { _svc.UpdateModel(mdl); _svc.CommitChanges(); }))
            {
                return(ReturnJsonFormSuccess());
            }
            return(PartialView("_EditModelImage", mModelImageVm));
        }
 public ActionResult _AddManufacturer(ManufacturerVM mManufacturerVm)
 {
     if (ModelState.IsValid)
     {
         var man = new Manufacturer();
         if (TryUpdateModel(man))
         {
             if (ExecuteRepositoryAction(() => { _svc.AddManufacturer(man); _svc.CommitChanges(); }))
             {
                 return(ReturnJsonFormSuccess());
             }
         }
     }
     return(PartialView("Edit", mManufacturerVm));
 }
Пример #3
0
 public ActionResult _Edit(StockEditVM mStock)
 {
     if (ModelState.IsValid)
     {
         var stk = _svc.GetStock(mStock.StockId);
         if (TryUpdateModel(stk))
         {
             if (ExecuteRepositoryAction(() => { _svc.UpdateStock(stk); _svc.CommitChanges(); }))
             {
                 return(ReturnJsonFormSuccess());
             }
         }
     }
     return(PartialView(mStock));
 }