public IActionResult AddOrUpdate([FromForm] Wms_Carrier model, [FromForm] string id) { var validator = new CarrierFluent(); 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 (_carrierServices.IsAny(c => c.CarrierNo == model.CarrierNo || c.CarrierName == model.CarrierName)) { return(BootJsonH((false, PubConst.Carrier1))); } model.CarrierId = PubId.SnowflakeId; model.CreateBy = UserDtoCache.UserId; bool flag = _carrierServices.Insert(model); return(BootJsonH(flag ? (flag, PubConst.Add1) : (flag, PubConst.Add2))); } else { model.CarrierId = id.ToInt64(); model.ModifiedBy = UserDtoCache.UserId; model.ModifiedDate = DateTimeExt.DateTime; var flag = _carrierServices.Update(model); return(BootJsonH(flag ? (flag, PubConst.Update1) : (flag, PubConst.Update2))); } }
public IActionResult Add(string id) { var model = new Wms_Carrier(); if (id.IsEmpty()) { return(View(model)); } else { model = _carrierServices.QueryableToEntity(c => c.CarrierId == SqlFunc.ToInt64(id)); return(View(model)); } }