public bool Update(User user) { using (var linqToDbTodoDatabase = new LinqToDbTodoDatabase(dbConfigurationName)) { return(linqToDbTodoDatabase.Update(userMapper.Map <LinqToDbUser>(user)) > 0); } }
public long Create(User user) { using (var linqToDbTodoDatabase = new LinqToDbTodoDatabase(dbConfigurationName)) { return(linqToDbTodoDatabase.InsertWithInt64Identity(userMapper.Map <LinqToDbUser>(user))); } }
public bool Update(TodoItem todoItem) { using (var linqToDbTodoDatabase = new LinqToDbTodoDatabase(dbConfigurationName)) { return(linqToDbTodoDatabase.Update(mapper.Map <LinqToDbTodoItem>(todoItem)) > 0); } }
public IEnumerable <TodoItem> ReadAll() { using (var linqToDbTodoDatabase = new LinqToDbTodoDatabase(dbConfigurationName)) { return(mapper.Map <IEnumerable <TodoItem> >(linqToDbTodoDatabase.TodoItems)); } }
public TodoItem Read(long id) { using (var linqToDbTodoDatabase = new LinqToDbTodoDatabase(dbConfigurationName)) { return(mapper.Map <TodoItem>(linqToDbTodoDatabase.TodoItems.Where(t => t.Id == id).FirstOrDefault())); } }
public bool Delete(long id) { using (var linqToDbTodoDatabase = new LinqToDbTodoDatabase(dbConfigurationName)) { return(linqToDbTodoDatabase.TodoItems.Where(t => t.Id == id).Delete() > 0); } }
public long Create(TodoItem todoItem) { using (var linqToDbTodoDatabase = new LinqToDbTodoDatabase(dbConfigurationName)) { var mappedItem = mapper.Map <LinqToDbTodoItem>(todoItem); return(linqToDbTodoDatabase.InsertWithInt64Identity(mappedItem)); } }
public IEnumerable <User> ReadAll() { using (var transaction = new TransactionScope()) { using (var linqToDbTodoDatabase = new LinqToDbTodoDatabase(dbConfigurationName)) { var userList = linqToDbTodoDatabase.Users.ToList(); var todoItemList = linqToDbTodoDatabase.TodoItems.ToList(); transaction.Complete(); return(userMapper.Map <IEnumerable <User> >(userList.Select(user => SelectTodoItems(user, todoItemList)))); } } }
public bool Delete(long id) { using (var transaction = new TransactionScope()) { using (var linqToDbTodoDatabase = new LinqToDbTodoDatabase(dbConfigurationName)) { linqToDbTodoDatabase.TodoItems.Where(t => t.User_Id == id).Delete(); var affectedRows = linqToDbTodoDatabase.Users.Where(u => u.Id == id).Delete(); transaction.Complete(); return(affectedRows > 0); } } }
public User Read(long id) { using (var transaction = new TransactionScope()) { using (var linqToDbTodoDatabase = new LinqToDbTodoDatabase(dbConfigurationName)) { var user = linqToDbTodoDatabase.Users.Where(u => u.Id == id).FirstOrDefault(); if (user != null) { user.TodoItems = linqToDbTodoDatabase.TodoItems.Where(t => t.User_Id == id).ToList(); } transaction.Complete(); return(userMapper.Map <User>(user)); } } }