public IActionResult WeighIn([FromBody] TransRecordViewModel model) { if (ModelState.IsValid) { if (model.IsOffline) { model.DTInbound = model.DTOfflineDate; model.WtInbound = model.OfflineWt; } else { model.DTInbound = DateTime.Now; model.WtInbound = model.WtInbound; } var currentShift = shiftRepository.GetCurrentShift(model.DTInbound.Value); model.ShiftId = currentShift.ShiftId; model.ShiftDate = currentShift.ShiftDate; var limit = transferLimitRepository.CheckLimit(new TransferLimitViewModel() { EffectiveDate = model.DTInbound, RawMaterialId = model.RawMaterialId, ShiftId = model.ShiftId }); if (limit == null || limit.ComputedLimitKg == 0) { ModelState.AddModelError(nameof(TransRecord.RawMaterialId), "No Limit was set. Transaction cannot continue"); return(BadRequest(ModelState.ToJson())); } model.TicketType = Enums.TicketType.IN.ToString(); //var currentUserId = userManager.GetUserId(HttpContext.User); model.WeigherInId = "cea78691-84a0-411b-b29d-89b17d8e4c69"; var remoteIpAddress = HttpContext.Connection.RemoteIpAddress; var clientMachine = clientMachineRepository.CheckClientMachine(remoteIpAddress.ToString()); //model.ReceiptNumPrefix = clientMachine.ReceiptNumPrefix; model.WeighingAreaId = clientMachine.WeighingAreaId; model.TransactionProcess = Enums.TransactionProcess.WEIGH_IN.ToString(); transRepository.WeighIn(model); return(Ok(model)); } else { return(BadRequest(ModelState.ToJson())); } }
public IActionResult CheckLimit([FromBody][Bind(nameof(TransRecordViewModel.TransactionProcess), nameof(TransRecordViewModel.IsOffline), nameof(TransRecordViewModel.DTInbound), nameof(TransRecordViewModel.DTOutbound), nameof(TransRecordViewModel.WtInbound), nameof(TransRecordViewModel.NetWt), nameof(TransRecordViewModel.ActualNetWt), nameof(TransRecord.NetWt), nameof(TransRecord.RawMaterialId), nameof(TransRecord.BinNum))] TransRecordViewModel model) { var isWeighIn = model.TransactionProcess == WeighingSystemCoreHelpers.Enums.Enums.TransactionProcess.WEIGH_IN.ToString(); var isWeighOut = model.TransactionProcess == WeighingSystemCoreHelpers.Enums.Enums.TransactionProcess.WEIGH_OUT.ToString(); var isUpdateOut = model.TransactionProcess == WeighingSystemCoreHelpers.Enums.Enums.TransactionProcess.UPDATE_OUT.ToString(); if (isWeighIn) { model.DTInbound = model.IsOffline ? model.DTOfflineDate : DateTime.Now; } else { model.DTOutbound = model.IsOffline ? model.DTOfflineDate : DateTime.Now; } DateTime?selectedDt = isWeighIn ? model.DTInbound : isWeighOut ? model.DTOutbound : isUpdateOut ? model.DTOutbound : model.DTInbound; var shiftId = _shiftRepository.GetCurrentShift(selectedDt ?? DateTime.Now).ShiftId; var transferLimitVM = new TransferLimitViewModel() { EffectiveDate = selectedDt, ShiftId = shiftId, RawMaterialId = model.RawMaterialId }; var result = _tlRepository.CheckLimit(transferLimitVM); return(Ok(result)); }