public async Task AddTheme(AddThemeViewModel input)
        {
            var theme = new Theme
            {
                PhotographyAddictedUserId = input.PhotographyAddictedUserId,
                AuthorOpinion             = input.AuthorOpinion,
                Title         = input.Title,
                ThemeCategory = input.ThemeCategory,
                CreationDate  = DateTime.UtcNow,
            };

            await themeDbSet.AddAsync(theme);

            await themeDbSet.SaveChangesAsync();

            var themeComment = new ThemeComment
            {
                PhotographyAddictedUser   = theme.PhotographyAddictedUser,
                PhotographyAddictedUserId = input.PhotographyAddictedUserId,
                ThemeId      = theme.Id,
                Theme        = theme,
                UserOpinion  = theme.AuthorOpinion,
                CreationDate = DateTime.UtcNow,
            };

            theme.ThemeComments.Add(themeComment);
            await themeDbSet.SaveChangesAsync();
        }
示例#2
0
        public async Task AddThemeComment(AddThemeCommentViewModel input)
        {
            var themeComment = new ThemeComment
            {
                PhotographyAddictedUserId = input.PhotographyAddictedUserId,
                PhotographyAddictedUser   = input.PhotographyAddictedUser,
                ThemeId      = input.ThemeId,
                Theme        = input.Theme,
                UserOpinion  = input.UserOpinion,
                CreationDate = DateTime.UtcNow,
            };

            await themeCommentDbSet.AddAsync(themeComment);

            await themeCommentDbSet.SaveChangesAsync();
        }