Esempio n. 1
0
        /// <summary>
        /// Поставить лайк
        /// </summary>
        public async Task <Unit> SendLike(string personId, string personFullName)
        {
            using var unitOfWork = _container.Resolve <IUnitOfWork>();
            var likeEntity = await unitOfWork.Session.GetAsync <LikeIdentityEntity>(personId);

            if (likeEntity == null)
            {
                var likeUpdateEntity = new LikeIdentityEntity(personId, personFullName, DateTimeService.GetDateTimeNow(), 1);
                await unitOfWork.Session.SaveOrUpdateAsync(likeUpdateEntity);
            }
            else
            {
                likeEntity.PersonFullname = personFullName;
                likeEntity.LastDateLike   = DateTimeService.GetDateTimeNow();
                likeEntity.LikeCount     += 1;
            }
            await unitOfWork.CommitAsync();

            return(Unit.Value);
        }
 /// <summary>
 /// Преобразовать в трансферную модель
 /// </summary>
 public static LikeIdentityResponse ToResponse(LikeIdentityEntity likeIdentityEntity) =>
 new LikeIdentityResponse(likeIdentityEntity.PersonId, likeIdentityEntity.PersonFullname,
                          likeIdentityEntity.LastDateLike, likeIdentityEntity.LikeCount);