예제 #1
0
        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();
        }
예제 #2
0
        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();
        }
예제 #3
0
        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();
        }