Ejemplo n.º 1
0
 public IActionResult AddOrUpdate([FromForm]Wms_storagerack model, [FromForm]string id)
 {
     var validator = new StorageRackFluent();
     var results = validator.Validate(model);
     var success = results.IsValid;
     if (!success)
     {
         string msg = results.Errors.Aggregate("", (current, item) => (current + item.ErrorMessage + "</br>"));
         return BootJsonH((PubEnum.Failed.ToInt32(), msg));
     }
     if (id.IsEmptyZero())
     {
         if (_storagerackServices.IsAny(c => c.StorageRackNo == model.StorageRackNo || c.StorageRackName == model.StorageRackNo))
         {
             return BootJsonH((false, PubConst.Warehouse5));
         }
         model.StorageRackId = PubId.SnowflakeId;
         model.CreateBy = UserDtoCache.UserId;
         bool flag = _storagerackServices.Insert(model);
         return BootJsonH(flag ? (flag, PubConst.Add1) : (flag, PubConst.Add2));
     }
     else
     {
         model.StorageRackId = id.ToInt64();
         model.ModifiedBy = UserDtoCache.UserId;
         model.ModifiedDate = DateTimeExt.DateTime;
         var flag = _storagerackServices.Update(model);
         return BootJsonH(flag ? (flag, PubConst.Update1) : (flag, PubConst.Update2));
     }
 }
Ejemplo n.º 2
0
        public async Task <IActionResult> AddOrUpdate([FromForm] Wms_storagerack model, [FromForm] string id)
        {
            var validator = new StorageRackFluent();
            var results   = validator.Validate(model);
            var success   = results.IsValid;

            if (!success)
            {
                string msg = results.Errors.Aggregate("", (current, item) => (current + item.ErrorMessage + "</br>"));
                return(BootJsonH((PubEnum.Failed.ToInt32(), msg)));
            }

            Wms_reservoirarea reservoirarea = await _client.Queryable <Wms_reservoirarea>().FirstAsync(
                x => x.ReservoirAreaId == model.ReservoirAreaId);

            if (reservoirarea == null)
            {
                return(BootJsonH((PubEnum.Failed.ToInt32(), "找不到库区")));
            }
            if (id.IsEmptyZero())
            {
                if (_storagerackServices.IsAny(c => c.StorageRackNo == model.StorageRackNo || c.StorageRackName == model.StorageRackNo))
                {
                    return(BootJsonH((false, PubConst.Warehouse5)));
                }

                model.StorageRackId     = PubId.SnowflakeId;
                model.ReservoirAreaName = reservoirarea.ReservoirAreaName;
                model.CreateBy          = UserDtoCache.UserId;
                model.CreateUser        = UserDtoCache.UserName;
                model.CreateDate        = DateTime.Now;
                model.ModifiedBy        = UserDtoCache.UserId;
                model.ModifiedUser      = UserDtoCache.UserName;
                model.ModifiedDate      = DateTime.Now;
                bool flag = _storagerackServices.Insert(model);
                return(BootJsonH(flag ? (flag, PubConst.Add1) : (flag, PubConst.Add2)));
            }
            else
            {
                model.StorageRackId     = id.ToInt64();
                model.ReservoirAreaName = reservoirarea.ReservoirAreaName;
                model.ModifiedBy        = UserDtoCache.UserId;
                model.ModifiedUser      = UserDtoCache.UserName;
                model.ModifiedDate      = DateTimeExt.DateTime;
                var flag = _storagerackServices.Update(model);
                return(BootJsonH(flag ? (flag, PubConst.Update1) : (flag, PubConst.Update2)));
            }
        }