public static MotionDetail ToDetail(this MotionEntity entity) { return(new MotionDetail { MotionId = entity.Id, Title = entity.Title, Description = entity.Description, PresenterName = entity.PresentingUser.UserName, OriginalSessionId = entity.OriginalSessionId, IsActive = entity.IsActive, IsTabled = entity.IsTabled, Votes = entity.Votes.Select(v => v.ToDetail()).ToList() }); }
// CREATE New public async Task <bool> CreateMotionAsync(MotionCreate model) { var currentSession = await _context.Sessions.FirstOrDefaultAsync(s => s.IsActive); if (currentSession == null) { return(false); } var newMotion = new MotionEntity { Title = model.Title, Description = model.Description, IsActive = true, IsTabled = false, PresentingUserId = _userId }; currentSession.OrdersOfBusiness.Add(newMotion); return(await _context.SaveChangesAsync() == 1); }