Esempio n. 1
0
        public ResponseView Modify(StorageView storage)
        {
            var model = _adapter.Adapt<Storage>(storage);

            var repo = ServiceLocator.Current.GetInstance<IStorageRepository>();

            var stor = repo.First(t => t.ID == model.ID);

            stor.Name = model.Name;
            stor.Address = model.Address;

            var result = new ResponseView();

            try
            {
                repo.Context.Commit();
                return result;
            }
            catch (Exception e)
            {
                result.IsSuccess = false;
                result.Message = "修改仓库失败";
                return result;
            }
        }
Esempio n. 2
0
        public ResponseView Add(StorageView storage)
        {
            var model = _adapter.Adapt<Storage>(storage);

            var repo = ServiceLocator.Current.GetInstance<IStorageRepository>();

            var result = new ResponseView();

            try
            {
                repo.Add(model);
                repo.Context.Commit();
                return result;
            }
            catch (Exception e)
            {
                result.IsSuccess = false;
                result.Message = "添加仓库失败";
                return result;
            }
        }