public async Task <bool> Update(ProblemDto problemDto) { DataAccess.Models.Problem value = Mapper.Map <DataAccess.Models.Problem>(problemDto); try { db.Entry(value).State = EntityState.Modified; await db.SaveChangesAsync(); return(true); } catch { return(false); } }
public async Task <bool> Create(ProblemDto problemDto) { try { DataAccess.Models.Problem value = Mapper.Map <DataAccess.Models.Problem>(problemDto); db.Entry(value).State = EntityState.Added; db.Problems.Add(value); await db.SaveChangesAsync(); return(true); } catch { return(false); } }
public async Task <bool> Delete(ProblemDto problemDto) { try { DataAccess.Models.Problem value = Mapper.Map <DataAccess.Models.Problem>(problemDto); value.DeletedDateTime = DateTime.Now; value.IsDeleted = true; db.Entry(value).State = EntityState.Modified; await db.SaveChangesAsync(); return(true); } catch { return(false); } }
public async Task <bool> CreateReletionUnit(ProblemDto problemDto) { try { DataAccess.Models.Problem value = Mapper.Map <DataAccess.Models.Problem>(problemDto); List <Department> problemDepartments = db.Departments.Where(d => d.Id == problemDto.DepartmentId).ToList(); value.Departments = problemDepartments; db.Problems.Add(value); await db.SaveChangesAsync(); return(true); } catch { return(false); } }