Exemplo n.º 1
0
        public IActionResult AddOrUpdate([FromForm] Wms_Customer model, [FromForm] string id)
        {
            var validator = new CustomerFluent();
            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 (_customerServices.IsAny(c => c.CustomerNo == model.CustomerNo || c.CustomerName == model.CustomerName))
                {
                    return(BootJsonH((false, PubConst.Customer1)));
                }
                model.CustomerId = PubId.SnowflakeId;
                model.CreateBy   = UserDtoCache.UserId;
                bool flag = _customerServices.Insert(model);
                return(BootJsonH(flag ? (flag, PubConst.Add1) : (flag, PubConst.Add2)));
            }
            else
            {
                model.CustomerId   = id.ToInt64();
                model.ModifiedBy   = UserDtoCache.UserId;
                model.ModifiedDate = DateTimeExt.DateTime;
                var flag = _customerServices.Update(model);
                return(BootJsonH(flag ? (flag, PubConst.Update1) : (flag, PubConst.Update2)));
            }
        }
Exemplo n.º 2
0
        public IActionResult Add(string id)
        {
            var model = new Wms_Customer();

            if (id.IsEmpty())
            {
                return(View(model));
            }
            else
            {
                model = _customerServices.QueryableToEntity(c => c.CustomerId == SqlFunc.ToInt64(id));
                return(View(model));
            }
        }