public async Task <bool> Update(CategoryDto categoryDto) { DataAccess.Models.Category value = Mapper.Map <DataAccess.Models.Category>(categoryDto); try { db.Entry(value).State = EntityState.Modified; await db.SaveChangesAsync(); return(true); } catch { return(false); } }
public async Task <bool> Create(CategoryDto categoryDto) { try { DataAccess.Models.Category value = Mapper.Map <DataAccess.Models.Category>(categoryDto); db.Entry(value).State = EntityState.Added; db.Categories.Add(value); await db.SaveChangesAsync(); return(true); } catch { return(false); } }
public async Task <bool> Delete(CategoryDto categoryDto) { try { DataAccess.Models.Category value = Mapper.Map <DataAccess.Models.Category>(categoryDto); value.DeletedDateTime = DateTime.Now; value.IsDeleted = true; db.Entry(value).State = EntityState.Modified; await db.SaveChangesAsync(); return(true); } catch { return(false); } }