public bool AddPersonDetails(PersonDetail objPerson, HttpPostedFileBase file) { var db = new PersonDetailsDBEntities(); using (var transaction = _dbContext.Database.BeginTransaction()) { try { _dbPerson.Insert(objPerson); _unitOfWork.SaveChanges(); PersonFile objFile = UploadFile(objPerson, file); _dbFile.Insert(objFile); _unitOfWork.SaveChanges(); transaction.Commit(); return(true); } catch (Exception ex) { transaction.Rollback(); throw ex; } finally { //log status } } }
public PersonDetailsService() { _dbContext = new PersonDetailsDBEntities(); _dbPerson = new GenericRepository <PersonDetail>(_dbContext); _dbFile = new GenericRepository <PersonFile>(_dbContext); _unitOfWork = new UnitOfWork(_dbContext); }