public async Task <bool> Update(OfferDto obj) { DataAccess.Models.Offer value = Mapper.Map <DataAccess.Models.Offer>(obj); try { db.Entry(value).State = EntityState.Modified; foreach (var files in db.Files) { db.Entry(files).State = EntityState.Modified; } await db.SaveChangesAsync(); return(true); } catch (Exception ex) { return(false); } }
public async Task <bool> Delete(OfferDto obj) { try { DataAccess.Models.Offer value = Mapper.Map <DataAccess.Models.Offer>(obj); 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> Create(OfferDto obj) { try { DataAccess.Models.Offer value = Mapper.Map <DataAccess.Models.Offer>(obj); value.DatePublication = DateTime.Now; db.Entry(value).State = EntityState.Added; db.Offers.Add(value); await db.SaveChangesAsync(); return(true); } catch { return(false); } }