public void Create(LineServiceModel input) { var line = new Line { From = input.From, To = input.To, ArrivalTime = input.ArrivalTime, DepartureTime = input.DepartureTime, Date = input.Date }; context.Lines.Add(line); context.SaveChanges(); }
public void Edit(UserServiceModel user) { if (!Contains(user.Id)) { throw new ArgumentException("Invalid user id!"); } var userFromDb = context.Users.SingleOrDefault(u => u.Id == user.Id); userFromDb.FirstName = user.FirstName; userFromDb.LastName = user.LastName; userFromDb.Address = user.Address; userFromDb.SSN = user.SSN; context.Users.Update(userFromDb); context.SaveChanges(); }
public void Make(TrainServiceModel input) { if (input.Capacity == 100) { return; } var train = new Train() { Name = input.Name, Capacity = input.Capacity, Fast = input.Fast }; context.Trains.Add(train); context.SaveChanges(); }