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); }
public void CreateNewUser(string username, string password) { User user = new User { UserName = username, Password = password }; ctx.Users.Add(user); ctx.SaveChanges(); }
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); }