/// <summary> /// Start action. /// </summary> /// <param name="id">Nullable id for search.</param> /// <returns>Session model.</returns> public async Task <IActionResult> Index(int?id) { Logger.Log.Debug($"Method {nameof(this.Index)}, id for search {id}"); if (!id.HasValue) { return(this.RedirectToAction( actionName: nameof(this.Index), controllerName: "Home")); } var session = await this.sessionRepository.GetByIdAsync(id.Value); if (session == null) { return(this.Content("Session not found.")); } var viewModel = new StormSessionViewModel() { DateCreated = session.DateCreated, Name = session.Name, Id = session.Id, }; Logger.Log.Debug($"Method {nameof(this.Index)}, model: {viewModel}"); return(this.View(viewModel)); }
public async Task <IActionResult> Index(int?id) { Logger.Debug($"{nameof(Index)} started processing request"); if (!id.HasValue) { Logger.Debug("Id is not passed, redirecting to the Home/Index"); return(RedirectToAction(actionName: nameof(Index), controllerName: "Home")); } var session = await _sessionRepository.GetByIdAsync(id.Value); if (session == null) { Logger.Debug($"Session with id {id} wasn't found"); return(Content("Session not found.")); } var viewModel = new StormSessionViewModel() { DateCreated = session.DateCreated, Name = session.Name, Id = session.Id }; Logger.Debug($"{nameof(Index)} finished processing request"); return(View(viewModel)); }
public async Task <IActionResult> Index(int?id) { if (!id.HasValue) { return(RedirectToAction(actionName: nameof(Index), controllerName: "Home")); } var session = await _sessionRepository.GetByIdAsync(id.Value); if (session == null) { return(Content("Session not found.")); } var viewModel = new StormSessionViewModel() { DateCreated = session.DateCreated, Name = session.Name, Id = session.Id }; _log4net.Debug("Debug message"); _log4net.Debug("Debug message2"); return(View(viewModel)); }
public async Task <IActionResult> Index(int?id) { if (Logger.inited == false) { Logger.InitLogger(); } if (!id.HasValue) { if (Logger.useLogs) { Logger.Log.Info("Homepage"); } return(RedirectToAction(actionName: nameof(Index), controllerName: "Home")); } var session = await _sessionRepository.GetByIdAsync(id.Value); if (session == null) { if (Logger.useLogs) { Logger.Log.Error("Session not found"); } return(Content("Session not found.")); } var viewModel = new StormSessionViewModel() { DateCreated = session.DateCreated, Name = session.Name, Id = session.Id }; if (Logger.useLogs) { Logger.Log.Debug($"session.DateCreated: {session.DateCreated} session.Name: {session.Name} session.Id: {session.Id}"); } return(View(viewModel)); }
public IActionResult Index(int?id) { if (!id.HasValue) { return(RedirectToAction("Index", "Home", null)); } var session = _sessionRepository.GetById(id.Value); if (session == null) { return(Content("Session not found.")); } var viewModel = new StormSessionViewModel() { DateCreated = session.DateCreated, Name = session.Name, Id = session.Id }; return(View(viewModel)); }