public int Add(byte[] content, string type, string source, int sourceId) { int id = ++MaxID; var image = new Image(id, content, type); { if (source == "user") { _imageDao.Add(image); //This is important to repeat in both branches because you won't be able to add it otherwise _userDao.AddImage(sourceId, id); } else if (source == "award") { _imageDao.Add(image); _awardDao.AddImage(sourceId, id); } else { throw new ArgumentException($"Incorrect source parameter: {source}"); } } return(id); }
public bool AddImage(int userId, string pathOfTheAddedImage) { return(_userDAO.AddImage(userId, pathOfTheAddedImage)); }