Ejemplo n.º 1
0
        public async Task <long> CreateMindfight(MindfightCreateDto mindfight)
        {
            if (!(_permissionChecker.IsGranted("CreateMindfights") ||
                  !_permissionChecker.IsGranted("ManageMindfights")))
            {
                throw new AbpAuthorizationException("Jūs neturite teisės sukurti naują protmūšį!");
            }

            var user = _userManager.Users.IgnoreQueryFilters().FirstOrDefault(u => u.Id == _userManager.AbpSession.UserId);

            if (user == null)
            {
                throw new UserFriendlyException("Vartotojas neegzistuoja!");
            }

            var newMindfight = new Models.Mindfight(user, mindfight.Title, mindfight.Description, mindfight.TeamsLimit,
                                                    mindfight.StartTime, mindfight.PrepareTime);

            return(await _mindfightRepository.InsertAndGetIdAsync(newMindfight));
        }
Ejemplo n.º 2
0
 private async Task UpdateMindfightActiveStatus(Models.Mindfight createdMindfight)
 {
     await _mindfightService.UpdateActiveStatus(createdMindfight.Id, true);
 }