Beispiel #1
0
        /// <summary>
        /// 添加仓库   zrx   2020年3月23日15:20:31
        /// </summary>
        /// <returns></returns>
        public CargoAddResponse AddCargo(CargoAddRequest request)
        {
            CargoAddResponse response = new CargoAddResponse();

            CargoInfo cargo = new CargoInfo()
            {
                CargoName     = request.CargoName,
                ShippingOrder = request.ShippingOrder,
                CargoWeight   = request.CargoWeight,
                CargoType     = request.CargoType,
                CargoState    = request.CargoState,
                CargoRemark   = request.CargoRemark
            };

            //获取名不能为空
            if (request == null || string.IsNullOrEmpty(request.CargoName))
            {
                response.Status  = false;
                response.Message = "货物名称不能为空";
                return(response);
            }
            //重量不能为0
            if (request.CargoWeight == 0)
            {
                response.Status  = false;
                response.Message = "重量不能为空";
                return(response);
            }
            //验证货物是否存在
            var shiporder = cdal.IsExistShipping(request.ShippingOrder);

            if (shiporder >= 1)
            {
                response.Status  = false;
                response.Message = "货物已存在";
                return(response);
            }

            var res = cdal.AddCargo(cargo);

            if (res > 0)
            {
                response.IsRegistSuccess = true;
                response.Message         = "添加货物成功";
            }
            else
            {
                response.Status  = false;
                response.Message = "添加货物失败";
            }

            return(response);
        }