示例#1
0
        public ActionResult SubInv_Destroy([DataSourceRequest] DataSourceRequest request, SubInvModel 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)));
        }
示例#2
0
        public ActionResult SubInv_Update([DataSourceRequest] DataSourceRequest request, SubInvModel 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)));
        }
示例#3
0
 public static SubInventory ToEntity(this SubInvModel model)
 {
     return(Mapper.Map <SubInvModel, SubInventory>(model));
 }