public bool EditNote(Note note, int ownerId) { var oldNote = _db.Notes.Find(note.Id); if (oldNote == null || !CheckNotebookAccess(note.NotebookId, ownerId)) { return(false); } _db.Entry(oldNote).CurrentValues.SetValues(note); _db.SaveChanges(); return(true); }
public bool EditTodo(Todo todo, int ownerId) { Todo OldTodo = _db.Todos.Find(todo.Id); var currentTodoList = _db.TodoLists.Find(todo.TodoListId); if (OldTodo != null && CheckTodoListAccess(currentTodoList.Id, ownerId)) { _db.Entry(OldTodo).CurrentValues.SetValues(todo); _db.SaveChanges(); return(true); } return(false); }
public bool EditEvent(Event e, int userId) { var oldEvent = _db.Events.Find(e.Id); if (oldEvent == null || !CheckEventValidity(e) || !CheckCalendarAccess(e.CalendarId, userId)) { return(false); } _db.Entry(oldEvent).CurrentValues.SetValues(e); _db.SaveChanges(); return(true); }
public bool EditContact(Contact contact) { Contact OldContact = _db.Contacts.Find(contact.Id); if (OldContact != null && OldContact.OwnerId == contact.OwnerId) { _db.Entry(OldContact).CurrentValues.SetValues(contact); _db.SaveChanges(); return(true); } else { return(false); } }
public bool EditUser(User newUser) { var user = _db.Users.Find(newUser.Id); if (user == null || string.IsNullOrWhiteSpace(newUser.Email) || string.IsNullOrWhiteSpace(newUser.Name) || string.IsNullOrWhiteSpace(newUser.Password) || !new EmailAddressAttribute().IsValid(user.Email)) { return(false); } _db.Entry(user).CurrentValues.SetValues(newUser); _db.SaveChanges(); return(true); }
public bool EditCalendar(Calendar calendar) { if (string.IsNullOrWhiteSpace(calendar.Title)) { return(false); } Calendar oldCalendar = _db.Calendars.Find(calendar.Id); if (oldCalendar != null && oldCalendar.OwnerId == calendar.OwnerId) { _db.Entry(oldCalendar).CurrentValues.SetValues(calendar); _db.SaveChanges(); return(true); } return(false); }
public bool EditNotebook(Notebook notebook) { if (string.IsNullOrWhiteSpace(notebook.Title)) { return(false); } Notebook oldNotebook = _db.Notebooks.Find(notebook.Id); if (oldNotebook != null && oldNotebook.OwnerId == notebook.OwnerId) { _db.Entry(oldNotebook).CurrentValues.SetValues(notebook); _db.SaveChanges(); return(true); } return(false); }
public bool EditTodoList(TodoList todoList) { if (string.IsNullOrWhiteSpace(todoList.Title)) { return(false); } TodoList oldTodoList = _db.TodoLists.Find(todoList.Id); if (oldTodoList != null && oldTodoList.OwnerId == todoList.OwnerId) { _db.Entry(oldTodoList).CurrentValues.SetValues(todoList); _db.SaveChanges(); return(true); } return(false); }