public IActionResult AddOrUpdate([FromForm] Wms_device device, [FromForm] string id) { var validator = new DeviceFluent(); var results = validator.Validate(device); 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 (_deviceServices.IsAny(c => c.SerialNo == device.SerialNo)) { return(BootJsonH((false, PubConst.Device1))); } device.DeviceId = PubId.SnowflakeId; device.CreateBy = UserDtoCache.UserId; bool flag = _deviceServices.Insert(device); return(BootJsonH(flag ? (flag, PubConst.Add1) : (flag, PubConst.Add2))); } else { device.DeviceId = id.ToInt64(); device.ModifiedBy = UserDtoCache.UserId; device.ModifiedDate = DateTimeExt.DateTime; var flag = _deviceServices.Update(device); return(BootJsonH(flag ? (flag, PubConst.Update1) : (flag, PubConst.Update2))); } }
public IActionResult Add(string id) { var model = new Wms_device(); if (id.IsEmpty()) { return(View(model)); } else { model = _deviceServices.QueryableToEntity(c => c.DeviceId == SqlFunc.ToInt64(id)); return(View(model)); } }