Exemple #1
0
 public PostViewModel(BllPost post, IEnumerable <BllTag> tags, BllBlog blog, BllUser user) : base(post, tags)
 {
     UserId    = user.Id;
     BlogId    = blog.Id;
     FirstName = user.FirstName;
     LastName  = user.LastName;
 }
Exemple #2
0
 public PostModel(BllPost post, IEnumerable <BllTag> tags)
 {
     PostId  = post.Id;
     Title   = post.Title;
     Content = post.Content;
     Tags    = tags;
 }
Exemple #3
0
 public PostModel(BllPost post, IEnumerable <BllTag> tags, int wordsInDescription,
                  Func <int, string, string> getDescription)
 {
     PostId  = post.Id;
     Title   = post.Title;
     Content = getDescription(wordsInDescription, post.Content);
     Tags    = tags;
 }
Exemple #4
0
 public static PostRatingViewModel ToPostRatingViewModel(this BllPost photo)
 {
     return(new PostRatingViewModel
     {
         Id = photo.PostId,
         NumberOfLikes = photo.NumberOfLikes
     });
 }
Exemple #5
0
 public static PostViewModel ToPostViewModel(this BllPost photo)
 {
     return(new PostViewModel
     {
         Id = photo.PostId,
         Image = photo.Image
     });
 }
Exemple #6
0
 public MainModel(BllUser user, BllBlog blog, BllPost lastPost)
 {
     UserId    = user.Id;
     BlogId    = blog.Id;
     Title     = blog.Title;
     FirstName = user.FirstName;
     LastName  = user.LastName;
     LastPost  = lastPost;
 }
Exemple #7
0
 public static DalPost ToDal(this BllPost post)
 {
     return(new DalPost
     {
         Id = post.Id,
         Content = post.Content,
         Title = post.Title,
         BlogId = post.BlogId
     });
 }
Exemple #8
0
 public static PostDetailsViewModel ToPostDetailsViewModel(this BllPost photo)
 {
     return(new PostDetailsViewModel
     {
         Id = photo.PostId,
         Name = photo.Name,
         Description = photo.Description,
         Image = photo.Image,
         NumberOfLikes = photo.NumberOfLikes,
         Tags = photo.Tags.Select(t => t.Text),
         UploadDate = photo.UploadDate.ToLocalTime(),
         UserId = photo.User.UserId,
         UserLikesIds = photo.UserLikesEntity.Select(ul => ul.UserLikesId)
     });
 }
Exemple #9
0
        public static EditPostModel ToEditPost(this BllPost post, IEnumerable <BllTag> tags)
        {
            var    stringTags = tags.Select(x => x.Name).ToList();
            string tagsConcat = "";

            if (stringTags.Any())
            {
                tagsConcat = stringTags.Aggregate((current, tag) => current + " " + tag);
            }
            return(new EditPostModel
            {
                BlogId = post.BlogId,
                Content = post.Content,
                Id = post.Id,
                Tags = tagsConcat,
                Title = post.Title
            });
        }
Exemple #10
0
        public async Task <bool> SendImage(BllPost post, int number = 1)
        {
            var connectionString = ConfigurationManager.AppSettings["serviceBusConnection"];
            var queueName        = ConfigurationManager.AppSettings["queue"];

            if (post.PostId == null)
            {
                throw new ArgumentNullException("PostId is null");
            }

            if (string.IsNullOrEmpty(post.Name))
            {
                throw new ArgumentNullException("Name is null");
            }

            if (string.IsNullOrEmpty(post.Description))
            {
                throw new ArgumentNullException("Description is null");
            }

            await using (ServiceBusClient client = new ServiceBusClient(connectionString))
            {
                // create a sender for the queue
                ServiceBusSender sender = client.CreateSender(queueName);
                var to = number == 1 ? 10000 : number;
                for (var i = 1; i < to; i++)
                {
                    post.PostId       = i * 11111;
                    post.Name        += (i * 10000).ToString();
                    post.Description += (i * 10000).ToString();

                    string messageBody = JsonConvert.SerializeObject(post);

                    // create a message
                    ServiceBusMessage message = new ServiceBusMessage(messageBody);

                    // send the message
                    await sender.SendMessageAsync(message);
                }
            }

            return(true);
        }
Exemple #11
0
 public bool Pay(BllPost post)
 {
     return(_payRepository.Pay(Mapper.CreateMap().Map <DalPost>(post)));
 }
Exemple #12
0
 public void Delete(BllPost entity)
 {
     repository.Delete(entity.ToDal());
     unitOfWork.Commit();
 }
Exemple #13
0
 public void Add(BllPost photo)
 {
     _postRepository.Insert(Mapper.CreateMap().Map <DalPost>(photo));
     Task.Run(() => _serviceBusConnector.SendImage(photo))
     ;
 }
Exemple #14
0
 public void Add(BllPost photo)
 {
     _postRepository.Insert(Mapper.CreateMap().Map <DalPost>(photo));
 }