Ejemplo n.º 1
0
        public StorageViewModel Get(string name)
        {
            StorageDto       storageDto       = storageAppService.Get(name);
            StorageViewModel storageViewModel = this.mapper.Map <StorageViewModel>(storageDto);

            return(storageViewModel);
        }
Ejemplo n.º 2
0
        public void Put(string id, StorageDto dto)
        {
            var customer = _unitOfWork.Storages.SingleOrDefault(w => w.Id == dto.Id);

            Mapper.Map(dto, customer);

            if (id != customer.Id)
            {
                return;
            }

            //customer.DateModified = DateTime.UtcNow;
            _unitOfWork.Storages.Update(customer);

            try
            {
                _unitOfWork.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (_unitOfWork.Storages.Any(e => e.Id == id))
                {
                    throw;
                }
            }
        }
Ejemplo n.º 3
0
        public HttpResponseMessage Delete(StorageDeleteModel storageDeleteModel)
        {
            StorageDto storageDto = this.mapper.Map <StorageDeleteModel, StorageDto>(storageDeleteModel);

            this.storageAppService.DeleteExistingStorage(storageDto);
            return(new HttpResponseMessage(HttpStatusCode.OK));
        }
Ejemplo n.º 4
0
        public ActionResult Update(StorageDto dto)
        {
            var t = _storageContract.Storages.FirstOrDefault(c => c.Id == dto.Id && !c.IsDeleted && c.IsEnabled);

            if (t != null && t.CheckLock)
            {
                return(Json(OperationResultType.Error, "当前仓库正在盘点已被锁定,请等待盘点完成"));
            }
            if (dto.IsDefaultStorage)
            {
                _storageContract.UpdateWord(dto.StoreId, c => c.IsDefaultStorage, new string[] { "IsDefaultStorage" }, new object[] { false });
            }
            if (dto.IsOrderStorage)
            {
                var orderStorages = _storageContract.Storages.Where(w => w.IsOrderStorage).ToList();
                foreach (var item in orderStorages)
                {
                    item.IsOrderStorage = false;
                }
                var sresult = _storageContract.Update(orderStorages.ToArray());
            }
            if (dto.IsTempStorage)
            {
                var tempStorages = _storageContract.Storages.Where(w => w.IsTempStorage).ToList();
                foreach (var item in tempStorages)
                {
                    item.IsOrderStorage = false;
                }
                var sresult = _storageContract.Update(tempStorages.ToArray());
            }
            var result = _storageContract.Update(dto);

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 5
0
        public HttpResponseMessage Insert(StorageCreateModel storageCreateModel)
        {
            StorageDto storageDto = this.mapper.Map <StorageCreateModel, StorageDto>(storageCreateModel);

            this.storageAppService.CreateNewStorage(storageDto);
            return(new HttpResponseMessage(HttpStatusCode.OK));
        }
Ejemplo n.º 6
0
 public void Save()
 {
     if (_isSaveDirty)
     {
         var storageDto = new StorageDto(_grid, Difficulty);
         _storageManager.Save(storageDto);
     }
 }
Ejemplo n.º 7
0
 public void DeleteExistingStorage(StorageDto storageDto)
 {
     using (NpgsqlConnection connection = this.databaseConnectionFactory.Instance.Create())
     {
         Storage storage = this.dtoToEntityMapper.Map <StorageDto, Storage>(storageDto);
         this.storageService.Delete(connection, storage);
     }
 }
Ejemplo n.º 8
0
 public StorageDto Get(string name)
 {
     using (NpgsqlConnection connection = this.databaseConnectionFactory.Instance.Create())
     {
         Storage    storage    = this.storageService.SelectByName(connection, new Name(name));
         StorageDto storageDto = this.dtoToEntityMapper.MapView <Storage, StorageDto>(storage);
         return(storageDto);
     }
 }
Ejemplo n.º 9
0
        public void Post(StorageDto dto)
        {
            var customer = new Storage();

            Mapper.Map(dto, customer);

            //customer.DateModified = DateTime.UtcNow;
            _unitOfWork.Storages.Update(customer);
            _unitOfWork.SaveChanges();
        }
Ejemplo n.º 10
0
        public void Handle(CardLoaded message)
        {
            this.CurrentCard        = message.Card;
            this.PrivateKeyPassword = message.PrivateKeyPassword;
            this.HasAccount         = true;

            var data = new StorageDto {
                PrivateKeyPassword = this.PrivateKeyPassword, PersonalCard = this.CurrentCard.Export()
            };

            var json = JsonConvert.SerializeObject(data);

            this.storageProvider.Save(json);
        }
Ejemplo n.º 11
0
        public void StoreAccessData(PersonalCard card, string privateKeyPassword)
        {
            this.CurrentCard        = card;
            this.PrivateKeyPassword = privateKeyPassword;
            this.HasAccount         = true;

            var data = new StorageDto {
                PrivateKeyPassword = this.PrivateKeyPassword, PersonalCard = this.CurrentCard.Export()
            };

            var json = JsonConvert.SerializeObject(data);

            this.storageProvider.Save(json);
        }
Ejemplo n.º 12
0
        public ActionResult UpdateState()
        {
            var             num  = Request["num"];
            var             stat = Request["stat"]; //1:成功 2:中断
            OperationResult res  = new OperationResult(OperationResultType.Error);

            if (stat != null && num != null)
            {
                var che = _checkerContract.Checkers.Where(c => c.CheckGuid == num).FirstOrDefault();
                if (che != null)
                {
                    Checker checker = _checkerContract.Checkers.Where(x => x.IsEnabled == true && x.IsDeleted == false)
                                      .OrderByDescending(x => x.CreatedTime)
                                      .FirstOrDefault(x => x.StorageId == che.StorageId && x.StoreId == che.StoreId);
                    if (checker != null && che.CheckGuid != checker.CheckGuid)
                    {
                        res.Message = "校验过的数据无法更改";
                        return(Json(res));
                    }


                    if (stat == "1")
                    {
                        che.CheckerState = CheckerFlag.Checked;
                        var ord = _storageContract.Storages.Where(c => c.Id == che.StorageId && c.IsDeleted == false && c.IsEnabled == true).FirstOrDefault();
                        if (ord != null)
                        {
                            ord.CheckLock = false;
                            StorageDto dto = AutoMapper.Mapper.Map <StorageDto>(ord);
                            _storageContract.Update(dto);
                        }
                    }
                    else if (stat == "2")
                    {
                        che.CheckerState = CheckerFlag.Interrupt;
                    }
                    else
                    {
                        che.CheckerState = CheckerFlag.Other;
                    }
                }
                if (che.CheckerState != CheckerFlag.Other)
                {
                    CheckerDto dto = AutoMapper.Mapper.Map <CheckerDto>(che);
                    res = _checkerContract.Update(dto);
                }
            }
            return(Json(res));
        }
Ejemplo n.º 13
0
        // POST /api/storages
        public IHttpActionResult AddStorage(StorageDto storageDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var storage = Mapper.Map <StorageDto, Storage>(storageDto);

            unitOfWork.Storages.AddStorage(storage);
            unitOfWork.Complete();

            storageDto.Id = storage.Id;

            return(Created(new Uri(Request.RequestUri + "/" + storage.Id), storageDto));
        }
Ejemplo n.º 14
0
        public ActionResult Create(StorageDto dto)
        {
            OperationResult resl = new OperationResult(OperationResultType.Error, "异常");
            int             err  = 0;

            if (dto.IsDefaultStorage)
            { //将已经存在的默认仓库覆盖为非默认
                _storageContract.UpdateWord(dto.StoreId, c => c.IsDefaultStorage, new string[] { "IsDefaultStorage" }, new object[] { false });
            }
            if (dto.IsOrderStorage)
            {
                var orderStorages = _storageContract.Storages.Where(w => w.IsOrderStorage).ToList();
                foreach (var item in orderStorages)
                {
                    item.IsOrderStorage = false;
                }
                var sresult = _storageContract.Update(orderStorages.ToArray());
            }
            if (dto.IsTempStorage)
            {
                var tempStorages = _storageContract.Storages.Where(w => w.IsTempStorage).ToList();
                foreach (var item in tempStorages)
                {
                    item.IsOrderStorage = false;
                }
                var sresult = _storageContract.Update(tempStorages.ToArray());
            }

            if (dto.StorageType == 0)//同一个店铺只能有一个线上仓库
            {
                var storag = _storageContract.Storages.FirstOrDefault(
                    c => c.StoreId == dto.StoreId && c.StorageType == 0 && !c.IsDeleted && c.IsEnabled);
                if (storag != null)
                {
                    resl.Message = "同一个店铺只能有一个线上仓库,已存在可用的线上仓库:" + storag.StorageName;
                    err         += 1;
                }
            }
            #region MyRegion

            #endregion
            if (err == 0)
            {
                resl = _storageContract.Insert(dto);
            }
            return(Json(resl, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 15
0
        // PUT /api/storages/1
        public void UpdateStorage(int id, StorageDto storageDto)
        {
            if (!ModelState.IsValid)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            var storageDb = unitOfWork.Storages.GetStorage(id);

            if (storageDb == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            Mapper.Map(storageDto, storageDb);
            //storageDb.Name = storage.Name;
            //storageDb.LocationID = storage.LocationID;

            unitOfWork.Complete();
        }
Ejemplo n.º 16
0
 public void Save(StorageDto storageDto)
 {
     _storageProvider.Save(nameof(StorageDto.Grid), _gridSerializer.Serialize(storageDto.Grid));
     _storageProvider.Save(nameof(StorageDto.Difficulty), storageDto.Difficulty);
 }
Ejemplo n.º 17
0
 public IActionResult Put(string id, [FromBody] StorageDto value)
 {
     _service.Put(id, value);
     return(Ok());
 }
Ejemplo n.º 18
0
 public IActionResult Post([FromBody] StorageDto value)
 {
     _service.Post(value);
     return(Ok());
 }