public BlogRepository(IDBContextFacade dbContext, IDataConverter dataConverter, IPostFactory postFactory) { _dBContext = dbContext; _dataConverter = dataConverter; _postFactory = postFactory; _db = _dBContext.GetDBContext(); }
//ADD public void AddImageToDb(string userID, HttpPostedFileBase file) { var image = _fileController.FileBaseToByteArray(file); var db = _dbContext.GetDBContext(); var currentUser = db.Users.Where(x => x.Id == userID).Single(); if (currentUser.Avatar == null) { currentUser.Avatar = new Picture() { AvatarInBytes = image }; } else { currentUser.Avatar.AvatarInBytes = image; } db.SaveChanges(); db.Dispose(); }
public UserRepository(IDBContextFacade dbContext) { _dBContext = dbContext; _db = _dBContext.GetDBContext(); }