public List <MawbAllocationModel> GetMawbAllocation(int TradelaneShipmentId, string Leg) { List <MawbAllocationModel> MAMList = new List <MawbAllocationModel>(); var userid = dbContext.TradelaneShipments.Where(a => a.TradelaneShipmentId == TradelaneShipmentId).FirstOrDefault().CustomerId; var CustomerDetail = new CustomerRepository().GetCustomerDetail(userid); List <TradelaneShipmentAllocation> Result = new List <TradelaneShipmentAllocation>(); if (!string.IsNullOrEmpty(Leg)) { Result = dbContext.TradelaneShipmentAllocations.Where(a => a.TradelaneShipmentId == TradelaneShipmentId && a.LegNum == Leg).ToList(); } else { Result = dbContext.TradelaneShipmentAllocations.Where(a => a.TradelaneShipmentId == TradelaneShipmentId).ToList(); } if (Result != null && Result.Count > 0) { foreach (var res in Result) { TimeZoneModal TZM = new TimeZoneModal(); var Timezone = dbContext.Timezones.Where(a => a.TimezoneId == res.TimezoneId).FirstOrDefault(); if (Timezone != null) { TZM.TimezoneId = Timezone.TimezoneId; TZM.Name = Timezone.Name; } MawbAllocationModel MAM = new MawbAllocationModel(); MAM.AgentId = res.AgentId.Value; MAM.AirlineId = res.AirlineId.Value; MAM.CreatedBy = res.CreatedBy.Value; MAM.CreatedOnUTC = res.CreatedOnUTC.Value; MAM.ETA = res.EstimatedDateofArrival != null?UtilityRepository.ConvertDatetoSpecifiedTimeZoneTime(res.EstimatedDateofArrival.Value, TZM) : (DateTime?)null; MAM.ETD = res.EstimatedDateofDelivery != null?UtilityRepository.ConvertDatetoSpecifiedTimeZoneTime(res.EstimatedDateofDelivery.Value, TZM) : (DateTime?)null; MAM.ETATime = res.EstimatedDateofArrival != null?UtilityRepository.ConvertToCustomerTimeZone(res.EstimatedDateofArrival.Value.TimeOfDay, TZM) : ""; MAM.ETDTime = res.EstimatedDateofDelivery != null?UtilityRepository.ConvertToCustomerTimeZone(res.EstimatedDateofDelivery.Value.TimeOfDay, TZM) : ""; MAM.TimezoneId = res.TimezoneId.Value; MAM.FlightNumber = res.FlightNumber; MAM.LegNum = res.LegNum; MAM.MAWB = res.MAWB; MAM.MawbAllocationId = res.TradelaneShipmentAllocationId; MAM.TradelaneId = res.TradelaneShipmentId.Value; MAMList.Add(MAM); } return(MAMList); } else { return(MAMList); } }