Beispiel #1
0
 public HttpResponseMessage Post(Quack quack)
 {
     _quackFacade.SaveQuack(quack);
     return Request.CreateResponse(HttpStatusCode.Created, "true");
 }
Beispiel #2
0
 private QuackDto QuackMapper(Quack quack, int userId = 0)
 {
     return new QuackDto
                {
                    Id = quack.ID,
                    Likes = quack.QuackLikes.Count(q => q.Active),
                    Message = quack.QuackContent.MessageText,
                    TimeSpan = GetTimeSpanInformation(quack.LastModifiedDate),
                    UserName = quack.User.UserName,
                    UserImage = quack.User.ProfileImage,
                    UserId = quack.User.ID,
                    LikeOrUnlike = VerifyLikeOrUnLike(quack, userId),
                    IsNew = quack.QuackTypeID == 1 ? true : false,
                    UserNickName = quack.User.UserName.Replace("DS\\", ""),
                    ConversationId = quack.ConversationID,
                    UserDisplayName = quack.User.FirstName + " " + quack.User.LastName,
                    LatestReply = GetRepliesInformation(quack.ID),
                    QuackImage =quack.QuackContent.Image
                };
 }
Beispiel #3
0
 private string VerifyLikeOrUnLike(Quack quack, int userId)
 {
     var check = quack.QuackLikes.FirstOrDefault(q => q.UserId == userId && q.Active && q.QuackId == quack.ID && q.Active);
     return check == null ? "Like" : "UnLike";
 }
Beispiel #4
0
        public void SaveQuack(Quack quack)
        {
            quack.CreatedDate = DateTime.Now;
            quack.LastModifiedDate = DateTime.Now;
            quack.Active = true;
            var quackType = _quackTypeRepository.GetQuackByQuackType(quack.QuackTypeID);

            quack.QuackType = quackType;
            var user = _userRepository.GetUserById(quack.UserID);
            quack.User = user;

            if (!String.IsNullOrEmpty(quack.QuackContent.ImageUrl))
            {
                var img = quack.QuackContent.ImageUrl;
                quack.QuackContent.ImageUrl = "Y";
                var currentImage = img.Substring(img.IndexOf(',') + 1);
                var data = Convert.FromBase64String(currentImage);
                quack.QuackContent.Image = data;
            }

            quack.QuackContent.CreatedDate = DateTime.Now;
            _quackRepository.SaveQuack(quack);

            if (quack.ConversationID != 0)
            {
                _quackRepository.UpdateQuack(quack.ConversationID);
            }
        }