public async Task <IActionResult> AddShipment(AddPNDTShipmentRequest sData) { _logger.LogInformation($"Invoking endpoint: {this.HttpContext.Request.GetDisplayUrl()}"); _logger.LogDebug($"Request - Adding PNDT shipment data - {JsonConvert.SerializeObject(sData)}"); var sampleShipment = await _pndtService.AddPNDTShipment(sData); _logger.LogInformation($"add samples to shipment for PNDT Specimen {sampleShipment}"); _logger.LogDebug($"Response - Adding PNDT shipment data - {JsonConvert.SerializeObject(sampleShipment)}"); return(Ok(new AddPNDTShipmentResponse { Status = sampleShipment.Status, Message = sampleShipment.Message, Shipment = sampleShipment.Shipment, })); }
public List <PNDTShipments> AddPNDTShipment(AddPNDTShipmentRequest sData) { string stProc = AddPNDTShipments; var pList = new List <SqlParameter>() { new SqlParameter("@PNDTFoetusId", sData.pndtFoetusId ?? sData.pndtFoetusId), new SqlParameter("@SenderName", sData.senderName ?? sData.senderName), new SqlParameter("@SenderContact", sData.senderContact ?? sData.senderContact), new SqlParameter("@SendingLocation", sData.sendingLocation ?? sData.sendingLocation), new SqlParameter("@ReceivingMolecularLabId", sData.receivingMolecularLabId), new SqlParameter("@ShipmentDateTime", sData.shipmentDateTime ?? sData.shipmentDateTime), new SqlParameter("@PDNTLocationId", sData.pndtLocationId), new SqlParameter("@UserId", sData.userId), }; var shipmentData = UtilityDL.FillData <PNDTShipments>(stProc, pList); return(shipmentData); }
public async Task <AddPNDTShipmentResponse> AddPNDTShipment(AddPNDTShipmentRequest sData) { var shipmentResponse = new AddPNDTShipmentResponse(); try { var msg = CheckShipmentValidation(sData); if (msg == "") { var shipmentDetails = _pndtData.AddPNDTShipment(sData); foreach (var shipment in shipmentDetails) { shipmentResponse.Shipment = shipment; if (!string.IsNullOrEmpty(shipmentResponse.Shipment.shipmentId)) { shipmentResponse.Status = "true"; shipmentResponse.Message = ""; } else { shipmentResponse.Status = "false"; shipmentResponse.Message = shipmentResponse.Shipment.errorMessage; } } } else { shipmentResponse.Status = "false"; shipmentResponse.Message = msg; } } catch (Exception e) { shipmentResponse.Status = "false"; shipmentResponse.Message = e.Message; } return(shipmentResponse); }
public string CheckShipmentValidation(AddPNDTShipmentRequest sData) { var message = ""; if (sData.pndtFoetusId == "") { message = "Foetus data is missing"; } else if (sData.senderName == "") { message = "Sender Name is missing"; } else if (sData.senderContact == "") { message = "Sender contact is missing"; } else if (sData.sendingLocation == "") { message = "Sender location is missing"; } else if (sData.receivingMolecularLabId <= 0) { message = "Invalid receiving MolecularLab"; } else if (sData.shipmentDateTime == "") { message = "Shipment date and time is missing"; } else if (sData.pndtLocationId <= 0) { message = "Invalid PNDT location"; } else if (sData.userId <= 0) { message = "Invalid User Id"; } return(message); }