예제 #1
0
 public vAnecdote(Anecdote model)
 {
     this.ID = model.ID;
     this.Title = model.Title;
     this.Description = model.Description;
     this.Time = model.Time.ToString();
     this.IsPublish = model.IsPublish;
     this.Browses = model.Browses;
     this.Sumamry = Helpers.String.CleanHTML(Helpers.HtmlFilter.Instance.SanitizeHtml(model.Sumamry));
 }
예제 #2
0
            public async Task <Unit> Handle(Command request, CancellationToken cancellationToken)
            {
                var anecdote = new Anecdote
                {
                    Id          = request.Id,
                    Title       = request.Title,
                    Description = request.Description,
                    Category    = request.Category,
                    Date        = request.Date,
                    City        = request.City,
                    Venue       = request.Venue
                };

                _context.Anecdotes.Add(anecdote);

                var user = await _context.Users.SingleOrDefaultAsync(x => x.UserName == _userAccessor.GetCurrentUsername());

                var favee = new UserAnecdote
                {
                    AppUser   = user,
                    Anecdote  = anecdote,
                    IsOwner   = true,
                    DateFaved = DateTime.Now
                };

                _context.UserAnecdotes.Add(favee);

                var success = await _context.SaveChangesAsync() > 0;

                if (success)
                {
                    return(Unit.Value);
                }

                throw new Exception("Problem saving changes");
            }
예제 #3
0
 private AnecdoteViewModel ModelMapping(Anecdote anecdote)
 {
     return(new AnecdoteViewModel {
         Id = anecdote.Id, Content = anecdote.Content, Date = anecdote.CreatedDate.ToShortDateString(), Owner = anecdote.Owner, Title = anecdote.Title, ShowedCount = anecdote.Detail.ShowedCount, LikedCount = anecdote.Detail.LikedCount, SavedCount = anecdote.Detail.SavedCount, ShareCount = anecdote.Detail.SharedCount, Status = anecdote.Status
     });
 }