public Domain.Todo.FindById.Models.Todo Find(int id) { using var dbContext = dataBaseContextFactory.Create(); var entity = dbContext.Todos.Single(x => x.id == id); return(new Domain.Todo.FindById.Models.Todo(id, entity.title, entity.description)); }
public IReadOnlyList <Domain.JobExperience.Find.Models.JobExperience> Find() { using var dbContext = dataBaseContextFactory.Create(); return(dbContext.JobExperiences .Select(Build) .ToList() .AsReadOnly()); }
public void Delete(int todoId) { using var dbContext = dataBaseContextFactory.Create(); var todo = dbContext.Todos.Single(x => x.id == todoId); dbContext.Todos.Remove(todo); dbContext.SaveChanges(); }
public Domain.Todo.Update.Models.Todo FindById(int todoId) { using var dbContext = dataBaseContextFactory.Create(); var entity = dbContext.Todos.First(x => x.id == todoId); return(new Domain.Todo.Update.Models.Todo( entity.id, entity.title, entity.description)); }
public void Update(Domain.Todo.Update.Models.Todo todo) { using var dbContext = dataBaseContextFactory.Create(); var entity = dbContext.Todos.First(x => x.id == todo.Id); entity.title = todo.Title; entity.description = todo.Description; entity.updated_date = todo.UpdationDate; dbContext.SaveChanges(); }
public IReadOnlyCollection <Domain.Todo.Search.Models.Todo> Search(string searchText) { using var dbContext = dataBaseContextFactory.Create(); return(dbContext.Todos .ToList() .Where(x => x.title.Contains(searchText) || x.description.Contains(searchText)) .Select(x => new Domain.Todo.Search.Models.Todo { Id = x.id, Title = x.title }) .ToList() .AsReadOnly()); }
public void Save(Domain.Todo.Create.Models.Todo todo) { using var dbContext = contextFactory.Create(); var entity = new Models.Todo { title = todo.Title, description = todo.Description, creation_date = todo.CreationDate }; dbContext.Todos.Add(entity); dbContext.SaveChanges(); }
public bool Exist(int todoId) { using var dbContext = dataBaseContextFactory.Create(); return(dbContext.Todos.Any(x => x.id == todoId)); }