public ActionResult SubInv_Destroy([DataSourceRequest] DataSourceRequest request, SubInventoryModel model)
        {
            if (model != null)
            {
                //productService.Destroy(model);
                SubInventory subinv = _subInventoryService.Find(model.SubInvCode);

                if (subinv == null)
                {
                    throw new Exception("Item does not exist.");
                }

                subinv.ObjectState = ObjectState.Deleted;

                _subInventoryService.Delete(subinv);

                _unitOfWorkAsync.SaveChanges();
            }

            return(Json(new[] { model }.ToDataSourceResult(request, ModelState)));
        }
        public ActionResult SubInv_Update([DataSourceRequest] DataSourceRequest request, SubInventoryModel model)
        {
            if (model != null && ModelState.IsValid)
            {
                //productService.Update(model);
                SubInventory subinv = Mappings.ToEntity(model);
                subinv.ObjectState  = ObjectState.Modified;
                subinv.ModifiedBy   = "I-ALI";
                subinv.ModifiedDate = DateTime.Now;

                _subInventoryService.Update(subinv);

                try
                {
                    _unitOfWorkAsync.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ItemExists(model.SubInvCode))
                    {
                        throw new Exception("Item does not exist.");
                    }

                    throw;
                }
            }

            return(Json(new[] { model }.ToDataSourceResult(request, ModelState)));
        }
Exemple #3
0
 public static SubInventory ToEntity(this SubInventoryModel model)
 {
     return(Mapper.Map <SubInventoryModel, SubInventory>(model));
 }