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; }
public PostModel(BllPost post, IEnumerable <BllTag> tags) { PostId = post.Id; Title = post.Title; Content = post.Content; Tags = tags; }
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; }
public static PostRatingViewModel ToPostRatingViewModel(this BllPost photo) { return(new PostRatingViewModel { Id = photo.PostId, NumberOfLikes = photo.NumberOfLikes }); }
public static PostViewModel ToPostViewModel(this BllPost photo) { return(new PostViewModel { Id = photo.PostId, Image = photo.Image }); }
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; }
public static DalPost ToDal(this BllPost post) { return(new DalPost { Id = post.Id, Content = post.Content, Title = post.Title, BlogId = post.BlogId }); }
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) }); }
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 }); }
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); }
public bool Pay(BllPost post) { return(_payRepository.Pay(Mapper.CreateMap().Map <DalPost>(post))); }
public void Delete(BllPost entity) { repository.Delete(entity.ToDal()); unitOfWork.Commit(); }
public void Add(BllPost photo) { _postRepository.Insert(Mapper.CreateMap().Map <DalPost>(photo)); Task.Run(() => _serviceBusConnector.SendImage(photo)) ; }
public void Add(BllPost photo) { _postRepository.Insert(Mapper.CreateMap().Map <DalPost>(photo)); }