public FrayteResult SaveTradelaneTracking(TradelaneUpdateTrackingModel TM) { var Shipment = dbContext.TradelaneShipments.Where(a => a.TradelaneShipmentId == TM.TradelaneShipmentId).FirstOrDefault(); var user = dbContext.Users.Where(a => a.UserId == Shipment.CustomerId).FirstOrDefault(); FrayteResult FR = new FrayteResult(); FR.Status = false; var Result = dbContext.TradelaneFlightDetails.Where(a => a.TradelaneFlightDetailId == TM.TradelaneFlightId).FirstOrDefault(); if (Result != null) { Result.TradelaneShipmentId = TM.TradelaneShipmentId; Result.FlightNumber = TM.FlightNo; Result.ArrivalAirportCode = TM.DestinationAirportCode; Result.DepartureAirportCode = TM.DepartureAirportCode; var Timezone = dbContext.Timezones.Where(a => a.TimezoneId == user.TimezoneId).FirstOrDefault(); TimeZoneModal TZM = new TimeZoneModal(); if (Timezone != null) { TZM.TimezoneId = Timezone.TimezoneId; TZM.Name = Timezone.Name; } Result.ArrivalDate = UtilityRepository.ConvertToUniversalTimeWitDate(TM.ArrivalTime, TM.ArrivalDate.Value, TZM); Result.DepartureDate = UtilityRepository.ConvertToUniversalTimeWitDate(TM.DepartureTime, TM.DepartureDate.Value, TZM); Result.BookingStatus = TM.BookingStatus; Result.Pieces = TM.TotalPeices; Result.TotalVolume = TM.Volume; Result.TotalWeight = TM.TotalWeight; dbContext.Entry(Result).State = System.Data.Entity.EntityState.Modified; dbContext.SaveChanges(); FR.Status = true; } else { TradelaneFlightDetail TlST = new TradelaneFlightDetail(); TlST.TradelaneShipmentId = TM.TradelaneShipmentId; TlST.FlightNumber = TM.FlightNo; TlST.ArrivalAirportCode = TM.DestinationAirportCode; TlST.DepartureAirportCode = TM.DepartureAirportCode; var Timezone = dbContext.Timezones.Where(a => a.TimezoneId == user.TimezoneId).FirstOrDefault(); TimeZoneModal TZM = new TimeZoneModal(); if (Timezone != null) { TZM.TimezoneId = Timezone.TimezoneId; TZM.Name = Timezone.Name; } TlST.ArrivalDate = UtilityRepository.ConvertToUniversalTimeWitDate(TM.ArrivalTime, TM.ArrivalDate.Value, TZM); TlST.DepartureDate = UtilityRepository.ConvertToUniversalTimeWitDate(TM.DepartureTime, TM.DepartureDate.Value, TZM); TlST.BookingStatus = TM.BookingStatus; TlST.Pieces = TM.TotalPeices; TlST.TotalVolume = TM.Volume; TlST.TotalWeight = TM.TotalWeight; dbContext.TradelaneFlightDetails.Add(TlST); dbContext.SaveChanges(); FR.Status = true; } return(FR); }
public IHttpActionResult SaveTradelaneTracking(TradelaneUpdateTrackingModel TrackingList) { var a = new UpdateTradelaneTrackingRepository().SaveTradelaneTracking(TrackingList); return(Ok(a)); }