Ejemplo n.º 1
0
 public bool Add(ImageEntity imageEntity)
 {
     try
     {
         return(_imageDao.Add(imageEntity));
     }
     catch
     {
         throw;
     }
 }
Ejemplo n.º 2
0
        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);
        }