Exemplo n.º 1
0
        public override IPost Add(IPost entity)
        {
            string CurrentUser = HttpContext.Current.User.Identity.GetUserId();

            try
            {
                byte[] imageBytes = null;
                if (entity.Image != null)
                {
                    imageBytes = FileHelper.ImageStringToByteArray(entity.Image.InputStream);
                }
                entity.Imagine = imageBytes;
                entity.IdUser  = CurrentUser;
                var entityData = _postsFactory.CopyTo(entity);
                _postsRepository.AddOrUpdate(entityData);
                Commit();
                return(_postsFactory.CopyFrom(entityData));
            }
            catch (Exception ex)
            {
                //LogService.Log.Error(ex);
            }
            return(null);
        }