public SaveResult Delete(TapTinTacNghiepResult entity) { return(ExecuteDbWithHandle(_logService, () => { using (var context = new TechOfficeEntities()) { var cv = context.TapTinTacNghieps.Single(x => x.Id == entity.Id && x.IsDeleted == false); cv.IsDeleted = true; cv.LastUpdatedBy = entity.LastUpdatedBy; cv.LastUpdated = DateTime.Now; context.Entry(cv).State = EntityState.Modified; return context.SaveChanges() > 0 ? SaveResult.SUCCESS : SaveResult.FAILURE; } })); }
public async Task <SaveResult> AddAsync(TapTinTacNghiepResult entity) { return(await ExecuteDbWithHandleAsync(_logService, async() => { using (var context = new TechOfficeEntities()) { var add = context.TapTinTacNghieps.Create(); add.Url = entity.Url; add.UserUploadId = entity.UserUploadId; add.TacNghiepId = entity.TacNghiepId; add.IsDeleted = entity.IsDeleted; add.CreatedBy = entity.CreatedBy; add.CreateDate = DateTime.Now; context.Entry(add).State = EntityState.Added; return await context.SaveChangesAsync() > 0 ? SaveResult.SUCCESS : SaveResult.FAILURE; } })); }
public async Task <SaveResult> UpdateAsync(TapTinTacNghiepResult entity) { return(await ExecuteDbWithHandleAsync(_logService, async() => { using (var context = new TechOfficeEntities()) { var update = context.TapTinTacNghieps.Single(x => x.Id == entity.Id && x.IsDeleted == false); update.Url = entity.Url; update.UserUploadId = entity.UserUploadId; update.TacNghiepId = entity.TacNghiepId; update.IsDeleted = entity.IsDeleted; update.LastUpdatedBy = entity.LastUpdatedBy; update.LastUpdated = DateTime.Now; context.Entry(update).State = EntityState.Modified; return await context.SaveChangesAsync() > 0 ? SaveResult.SUCCESS : SaveResult.FAILURE; } })); }