Example #1
0
        public async Task <UpdateSessionEventResponse> UpdateSessionEvent(UpdateSessionEventRequest request)
        {
            var session = await _sessionService.GetAuthenticatedSession();

            var response = new UpdateSessionEventResponse();

            using (var uow = _uowFactory.GetUnitOfWork())
            {
                await uow.SessionRepo.UpdateSessionEvent(new Infrastructure.Repositories.SessionRepo.Models.UpdateSessionEventRequest()
                {
                    Id          = request.Id,
                    Description = request.Description,
                    Updated_By  = session.User.Entity.Id
                });

                uow.Commit();
            }

            _cache.Remove(CacheConstants.SessionEvents);

            var sessionEvents = await _cache.SessionEvents();

            var sessionEvent = sessionEvents.FirstOrDefault(c => c.Id == request.Id);

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

            response.Notifications.Add($"Session event '{sessionEvent.Key}' has been updated", NotificationTypeEnum.Success);
            return(response);
        }
Example #2
0
        public async Task OnGet()
        {
            var response = await _sessionService.GetSessionEvent(new GetSessionEventRequest()
            {
                Id = Id
            });

            Key      = response.SessionEvent.Key;
            FormData = new UpdateSessionEventRequest()
            {
                Id          = response.SessionEvent.Id,
                Description = response.SessionEvent.Description
            };
        }
        public async Task <IActionResult> EditSessionEvent(UpdateSessionEventRequest request)
        {
            if (ModelState.IsValid)
            {
                var response = await _adminService.UpdateSessionEvent(request);

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

            return(View(viewModel));
        }
Example #4
0
        public async Task UpdateSessionEvent(UpdateSessionEventRequest request)
        {
            var sqlStoredProc = "sp_session_event_update";

            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 updated");
            }
        }
Example #5
0
        public async Task <IActionResult> OnGet()
        {
            var response = await _sessionService.GetSessionEvent(new GetSessionEventRequest()
            {
                Id = Id
            });

            if (!response.IsSuccessful)
            {
                return(NotFound());
            }

            Key      = response.SessionEvent.Key;
            FormData = new UpdateSessionEventRequest()
            {
                Id          = response.SessionEvent.Id,
                Description = response.SessionEvent.Description
            };

            return(Page());
        }
Example #6
0
        public async Task <UpdateSessionEventResponse> UpdateSessionEvent(UpdateSessionEventRequest request)
        {
            var sessionUser = await _sessionManager.GetUser();

            var response = new UpdateSessionEventResponse();

            using (var uow = _uowFactory.GetUnitOfWork())
            {
                await uow.SessionRepo.UpdateSessionEvent(new Repositories.DatabaseRepos.SessionRepo.Models.UpdateSessionEventRequest()
                {
                    Id          = request.Id,
                    Description = request.Description,
                    Updated_By  = sessionUser.Id
                });

                uow.Commit();
            }

            _cache.Remove(CacheConstants.SessionEvents);

            var sessionEvents = await _cache.SessionEvents();

            var sessionEvent = sessionEvents.FirstOrDefault(c => c.Id == request.Id);

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

            response.Notifications.Add($"Session event '{sessionEvent.Key}' has been updated", NotificationTypeEnum.Success);
            return(response);
        }
Example #7
0
 public EditSessionEventModel(ISessionService sessionService)
 {
     _sessionService = sessionService;
     FormData        = new UpdateSessionEventRequest();
 }