Example #1
0
        public void SetTaskStatus(int taskId, string newStatus)
        {
            var task = dx.Tasks.Where(t => t.Id == taskId).Single();

            task.Status = newStatus;
            dx.SaveChanges();
        }
        // private method that saves and fires statechanged event

        private bool SaveChanges(int expected)
        {
            int changed = ctx.SaveChanges();

            if (changed >= expected)
            {
                StateChanged?.Invoke(this);
            }
            return(changed >= expected);
        }
Example #3
0
        public void CreateNewUser(string username, string password)
        {
            User user = new User
            {
                UserName = username,
                Password = password
            };

            ctx.Users.Add(user);
            ctx.SaveChanges();
        }
Example #4
0
        public Reservation MakeReservation(string userName, RoomType roomType, DateTime from, DateTime to)
        {
            var user = dx.Users.Where(u => u.UserName == userName).Single();

            var reservation = new Reservation();

            reservation.Type  = roomType;
            reservation.Start = from;
            reservation.End   = to;
            reservation.User  = user;
            dx.Reservations.Add(reservation);
            dx.SaveChanges();

            return(reservation);
        }