Ejemplo n.º 1
0
        public bool DeleteComment(int commentId)
        {
            ISession session = null;
            bool     result  = false;

            try
            {
                session = DataLayer.GetSession();
                Comment comment = session.Load <Comment>(commentId);

                CommentDTO commentDTO = new CommentDTO(comment);
                session.Delete(comment);

                MessageQueueManager manager = MessageQueueManager.Instance;
                manager.PublishMessage(commentDTO.BelongsToNewsId, commentDTO.Id, commentDTO, MessageOperation.Delete);

                session.Flush();
                session.Close();
                result = true;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                if (session != null)
                {
                    session.Close();
                }
            }

            return(result);
        }
Ejemplo n.º 2
0
        //This Shit needs testing
        public NewsDTO CreateNews(NewsDTO news, int userId)
        {
            NewsDTO dataResult = newsData.CreateNews(news, userId);

            //if (news.BackgroundPicture != null)
            //{
            //    dataResult.BackgroundPicture.PictureData = news.BackgroundPicture.PictureData;
            //}

            //TODO ovo uopste ne izgleda dobro, ne znam kako bi bolje mogle da se ucitavaju slike

            for (int i = 0; i < news.Pictures.Count; i++)
            {
                PictureDTO dto = dataResult.Pictures[i];
                dto.PictureData = news.Pictures[i].PictureData;
            }

            if (dataResult != null)
            {
                MessageQueueManager manager = MessageQueueManager.Instance;
                manager.PublishMessage(dataResult.Id, dataResult.Id, dataResult, MessageOperation.Insert);
            }

            return(dataResult);
        }
Ejemplo n.º 3
0
        public PictureDTO CreatePicture(PictureDTO pic)
        {
            PictureDTO dataResult = pictureData.CreatePicture(pic);

            if (dataResult != null)
            {
                MessageQueueManager menager = MessageQueueManager.Instance;
                menager.PublishMessage(dataResult.BelongsToNewsId, dataResult.Id, dataResult, MessageOperation.Insert);
            }
            return(dataResult);
        }
Ejemplo n.º 4
0
        public bool PutPicture(int pictureId, int newsId, byte[] pictureData)
        {
            bool res = loader.SaveMedia(pictureId, newsId, pictureData);

            if (res)
            {
                MessageQueueManager manager = MessageQueueManager.Instance;
                manager.PublishMessage(newsId, pictureId, new PictureUpdateObject(pictureId, newsId), MessageOperation.Update);
            }
            return(res);
        }
Ejemplo n.º 5
0
        public CommentDTO CreateComment(CommentDTO value)
        {
            CommentDTO dataResult = commentDataAccess.CreateComment(value);

            if (dataResult != null)
            {
                MessageQueueManager menager = MessageQueueManager.Instance;
                menager.PublishMessage(dataResult.BelongsToNewsId, dataResult.Id, dataResult, MessageOperation.Insert);
            }
            return(dataResult);
        }
Ejemplo n.º 6
0
        public bool DeletePicture(int id)
        {
            PictureDTO resultData = pictureData.DeletePicture(id);
            bool       result     = false;

            if (resultData != null)
            {
                result = loader.DeleteMedia(resultData.Id, resultData.BelongsToNewsId);
                MessageQueueManager manager = MessageQueueManager.Instance;
                manager.PublishMessage(resultData.BelongsToNewsId, resultData.Id, resultData, MessageOperation.Delete);
            }
            return(result);
        }
Ejemplo n.º 7
0
        public bool UpdateComment(int id, string content)
        {
            bool       result     = false;
            CommentDTO dataResult = commentDataAccess.UpdateComment(id, content);

            if (dataResult != null)
            {
                MessageQueueManager menager = MessageQueueManager.Instance;
                menager.PublishMessage(dataResult.BelongsToNewsId, dataResult.Id, dataResult, MessageOperation.Update);
                result = true;
            }
            return(result);
        }
Ejemplo n.º 8
0
        public bool DeleteAudio(int audioId)
        {
            bool     result     = false;
            AudioDTO resultData = audioDataAccess.DeleteAudio(audioId);

            if (resultData.AudioData != null)
            {
                result = loader.SaveMedia(resultData.Id, resultData.BelongsToNewsId, resultData.GetAudioBytes());

                MessageQueueManager manager = MessageQueueManager.Instance;
                manager.PublishMessage(resultData.BelongsToNewsId, resultData.Id, resultData, MessageOperation.Delete);
            }
            return(result);
        }
Ejemplo n.º 9
0
        public bool UpdatePicture(PictureDTO pic)
        {
            bool       resault    = false;
            PictureDTO dataResult = pictureData.UpdatePicture(pic);

            if (dataResult != null)
            {
                loader.SaveMedia(dataResult.Id, dataResult.BelongsToNewsId, dataResult.GetPictureBytes());

                MessageQueueManager menager = MessageQueueManager.Instance;
                menager.PublishMessage(dataResult.BelongsToNewsId, dataResult.Id, dataResult, MessageOperation.Update);
                resault = true;
            }
            return(resault);
        }
Ejemplo n.º 10
0
        public SimpleNewsDTO UpdateNews(SimpleNewsDTO simpleDTO, int userId)
        {
            SimpleNewsDTO dataResult = newsData.UpdateNews(simpleDTO, userId);

            if (dataResult != null && simpleDTO.BackgroundPicture != null)
            {
                //loader.SaveMedia(simpleDTO.BackgroundPicture.Id, simpleDTO.Id, simpleDTO.BackgroundPicture.GetPictureBytes());
                dataResult.BackgroundPicture.PictureData = simpleDTO.BackgroundPicture.PictureData;
            }

            if (dataResult != null)
            {
                MessageQueueManager manager = MessageQueueManager.Instance;
                manager.PublishMessage(dataResult.Id, dataResult.Id, dataResult, MessageOperation.Update);
            }
            return(dataResult);
        }
Ejemplo n.º 11
0
        public bool DeleteNews(int newsId)
        {
            NewsDTO dataResult = newsData.DeleteNews(newsId);
            bool    result     = false;

            if (dataResult != null)
            {
                foreach (PictureDTO p in dataResult.Pictures)
                {
                    loader.DeleteMedia(p.Id, dataResult.Id);
                }
                if (dataResult.BackgroundPicture != null)
                {
                    loader.DeleteMedia(dataResult.BackgroundPicture.Id, dataResult.Id);
                }


                MessageQueueManager manager = MessageQueueManager.Instance;
                manager.PublishMessage(dataResult.Id, dataResult.Id, dataResult, MessageOperation.Delete);
                result = true;
            }
            return(result);
        }