// CREATE New
        public async Task <bool> CreateAmendmentAsync(AmendmentCreate model)
        {
            var sessionService = new SessionService();

            sessionService.SetUserId(_userId);

            var currentSessionId = await sessionService.GetCurrentSessionIdAsync();

            if (currentSessionId == 0)
            {
                return(false);
            }

            var amendment = new AmendmentEntity
            {
                RuleId            = model.RuleId,
                Title             = model.Title,
                Description       = model.Description,
                IsActive          = true,
                PresentingUserId  = _userId,
                OriginalSessionId = currentSessionId,
            };

            _context.Amendments.Add(amendment);
            return(await _context.SaveChangesAsync() == 1);
        }
 public static AmendmentDetail ToDetail(this AmendmentEntity entity)
 {
     return(new AmendmentDetail
     {
         AmendmentId = entity.Id,
         RuleId = entity.RuleId,
         Title = entity.Title,
         Description = entity.Description,
         PresenterName = entity.PresentingUser.UserName,
         OriginalSessionId = entity.OriginalSessionId,
         IsActive = entity.IsActive,
         IsTabled = entity.IsTabled,
         IsPassed = entity.IsPassed,
         Votes = entity.Votes.Select(v => v.ToDetail()).ToList()
     });
 }