Exemplo n.º 1
0
        /// <summary>
        /// Update comment
        /// </summary>
        /// <param name="e">Updated comment entity</param>
        /// <exception cref="ArgumentNullException"></exception>
        public async Task Update(BllComment e)
        {
            if (e == null)
            {
                throw new ArgumentNullException(nameof(e));
            }

            await context.CommentsRepository.Update(e.ToDalCommentary());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Add comment
        /// </summary>
        /// <param name="text">Comment text</param>
        /// <param name="userName">User login</param>
        /// <param name="lotId">Id of the lot</param>
        /// <returns>Id of added comment</returns>
        public async Task <int> PostComment(string text, string userName, int lotId)
        {
            if (string.IsNullOrEmpty(text))
            {
                throw new ArgumentNullException(nameof(text));
            }

            if (string.IsNullOrEmpty(userName))
            {
                throw new ArgumentNullException(nameof(userName));
            }

            var user = (await context.UserStore.FindByNameAsync(userName)).ToBllUser();

            var comment = new BllComment()
            {
                Date = DateTime.Now,
                Lot  = lotId,
                Text = text,
                User = user.Id
            };

            return(await context.CommentsRepository.Create(comment.ToDalCommentary()));
        }