public async Task <IActionResult> CreateSessionEvent(CreateSessionEventRequest request)
        {
            if (ModelState.IsValid)
            {
                var response = await _adminService.CreateSessionEvent(request);

                if (response.IsSuccessful)
                {
                    AddNotifications(response);
                    return(RedirectToAction(nameof(AdminController.SessionEventManagement)));
                }
                AddFormErrors(response);
            }
            var viewModel = new CreateSessionEventViewModel(request);

            return(View(viewModel));
        }
Example #2
0
        public async Task <CreateSessionEventResponse> CreateSessionEvent(CreateSessionEventRequest request)
        {
            var sessionUser = await _sessionManager.GetUser();

            var response = new CreateSessionEventResponse();

            var sessionEvents = await _cache.SessionEvents();

            var sessionEvent = sessionEvents.FirstOrDefault(se => se.Key == request.Key);

            if (sessionEvent != null)
            {
                response.Notifications.AddError($"A session event already exists with the key {request.Key}");
                return(response);
            }

            int id;

            using (var uow = _uowFactory.GetUnitOfWork())
            {
                id = await uow.SessionRepo.CreateSessionEvent(new Repositories.DatabaseRepos.SessionRepo.Models.CreateSessionEventRequest()
                {
                    Key         = request.Key,
                    Description = request.Description,
                    Created_By  = sessionUser.Id
                });

                uow.Commit();
            }

            _cache.Remove(CacheConstants.SessionEvents);

            await _sessionManager.WriteSessionLogEvent(new Models.ManagerModels.Session.CreateSessionLogEventRequest()
            {
                EventKey = SessionEventKeys.SessionEventCreated,
                Info     = new Dictionary <string, string>()
                {
                    { "Key", request.Key }
                }
            });

            response.Notifications.Add($"Session event '{request.Key}' has been created", NotificationTypeEnum.Success);
            return(response);
        }
Example #3
0
        public async Task <int> CreateSessionEvent(CreateSessionEventRequest request)
        {
            var sqlStoredProc = "sp_session_event_create";

            var response = await DapperAdapter.GetFromStoredProcAsync <int>
                           (
                storedProcedureName : sqlStoredProc,
                parameters : request,
                dbconnectionString : DefaultConnectionString,
                sqltimeout : DefaultTimeOut,
                dbconnection : _connection,
                dbtransaction : _transaction);

            if (response == null || response.FirstOrDefault() == 0)
            {
                throw new Exception("No items have been created");
            }
            return(response.FirstOrDefault());
        }
Example #4
0
        public async Task <CreateSessionEventResponse> CreateSessionEvent(CreateSessionEventRequest request)
        {
            var session = await _sessionService.GetAuthenticatedSession();

            var response = new CreateSessionEventResponse();

            var sessionEvents = await _cache.SessionEvents();

            var sessionEvent = sessionEvents.FirstOrDefault(se => se.Key == request.Key);

            if (sessionEvent != null)
            {
                response.Notifications.AddError($"A session event already exists with the key {request.Key}");
                return(response);
            }

            int id;

            using (var uow = _uowFactory.GetUnitOfWork())
            {
                id = await uow.SessionRepo.CreateSessionEvent(new Infrastructure.Repositories.SessionRepo.Models.CreateSessionEventRequest()
                {
                    Key         = request.Key,
                    Description = request.Description,
                    Created_By  = session.User.Entity.Id
                });

                uow.Commit();
            }

            _cache.Remove(CacheConstants.SessionEvents);

            await _sessionService.WriteSessionLogEvent(new Models.ServiceModels.Session.CreateSessionLogEventRequest()
            {
                EventKey = SessionEventKeys.SessionEventCreated
            });

            response.Notifications.Add($"Session event '{request.Key}' has been created", NotificationTypeEnum.Success);
            return(response);
        }
 public CreateSessionEventModel(ISessionService sessionService)
 {
     _sessionService = sessionService;
     FormData        = new CreateSessionEventRequest();
 }