public bool Save(FlightContractsModel flight) { if (flight == null) { throw new ArgumentNullException(nameof(flight)); } using (_context) { this._flight = this._context.Flight.FirstOrDefault(x => x.Id == flight.Id); this._flight = ModelConverterHelper.GetModelFromContract(flight); this._context.SaveChanges(); } return(true); }
public bool Add(FlightContractsModel model) { if (model == null) { throw new ArgumentNullException(nameof(model)); } using (_context) { this._flight = ModelConverterHelper.GetModelFromContract(model); this._context.Flight.Add(_flight); this._context.SaveChanges(); } return(true); }
public static FlightModel GetModelFromContract(FlightContractsModel flight) { return(new FlightModel { Id = flight.Id, ArrivalCity = flight.ArrivalCity, ArrivalTime = flight.ArrivalTime, DepartureCity = flight.DepartureCity, DepartureTime = flight.DepartureTime, FlightType = flight.Type, Gate = GetModelFromContract(flight.Gate), Plane = GetModelFromContract(flight.Plane), Price = flight.Price, Status = flight.Status }); }