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)); }
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)); }