Example #1
0
 /// <summary>
 /// Converts a <see cref="Shook"/> to <see cref="RecentShooksCellView"/> item.
 /// </summary>
 /// <param name="_shook">A Shook you want to convert.</param>
 public RecentShooksCellView(Shook _shook)
 {
     Title       = _shook.Title;
     Description = _shook.Description;
     End         = CalculateEndTime(_shook.EndTime);
     Color       = "#fc85ae";
 }
Example #2
0
        public void CreateShook(Shook shook)
        {
            if (CheckShook(shook))
            {
                var shookDto = new ShookDto
                {
                    Title       = shook.Title,
                    Description = shook.Description,
                    Creator     = _dbContext.GetUserDtoByUsername(_jwtUtility.GetUsername()),
                    StartTime   = shook.StartTime,
                    EndTime     = shook.EndTime
                };

                shookDto.ShookUsers.Add(new UserShookDto
                {
                    Shook      = shookDto,
                    ShookDtoId = shookDto.Id,
                    User       = shookDto.Creator,
                    UserDtoId  = shookDto.Creator.Id
                });

                _dbContext.Shooks.Add(shookDto);
                _dbContext.SaveChanges();
            }
        }
Example #3
0
 /// <summary>
 /// Fires the <see cref="onShook"/> and <see cref="Shook"/> events.
 /// </summary>
 private void OnShook()
 {
     if (!IsActive)
     {
         IsActive = true;
         onShook?.Invoke();
         Shook?.Invoke(this, EventArgs.Empty);
     }
 }
Example #4
0
        public void Join(Shook shook)
        {
            var username = _jwtUtility.GetUsername();
            var userDto  = _dbContext.GetUserDtoByUsername(username);
            var shookDto = _dbContext.GetShookDtoByShook(shook);

            UserShookDto userShookDto = new UserShookDto
            {
                Shook      = shookDto,
                ShookDtoId = shookDto.Id,
                User       = userDto,
                UserDtoId  = userDto.Id
            };

            shookDto.ShookUsers.Add(userShookDto);
            _dbContext.Shooks.Update(shookDto);
            _dbContext.SaveChanges();
        }
Example #5
0
        /// <summary>
        /// Test method for filling the ListView.
        /// </summary>
        /// <returns>A list with the recent shooks of the user as
        /// <see cref="RecentShooksCellView"/></returns>
        private List <RecentShooksCellView> CreateListOfRecentShooksCellViews()
        {
            Shook shook1 = new Shook
            {
                Title       = "Test",
                Description = "Test Description",
                EndTime     = DateTime.Now
            };

            List <RecentShooksCellView> recentShooksCellViews = new List <RecentShooksCellView>
            {
                new RecentShooksCellView(shook1),
                new RecentShooksCellView(shook1),
                new RecentShooksCellView(shook1),
                new RecentShooksCellView(shook1)
            };

            return(recentShooksCellViews);
        }
Example #6
0
 public ShookDto GetShookDtoByShook(Shook shook)
 {
     return(Shooks.SingleAsync(s => s.Id == shook.Id).Result);
 }
Example #7
0
 private bool CheckShook(Shook shook)
 {
     return(true);
 }