public ActionResult SubmitRegisterEntry(RegisterEntryModel model) { try { var mappedModel = Mapper.Map <YearlyBackend.RegisterEntry.RegisterEntryModel>(model); var command = new AddRegisterEntryCommand(mappedModel, User.Identity.Name); var result = _mediator.Send(command).Result; if (result.ValidatedOk) { ViewBag.Title = "Mätarställning registrerad"; ViewBag.SubTitle = "Mätarställningen blev registrerad"; } else { ViewBag.Title = "Fel vid registrering"; ViewBag.SubTitle = result.ValidationError; } return(View(model)); } catch (Exception e) { _logger.TrackException(e); ViewBag.Title = "Ett fel uppstod"; ViewBag.SubTitle = "Ett fel uppstod vid registrering av mätarställning"; return(View(model)); } }
// GET: RegisterEntry public ActionResult RegisterEntryView() { ViewBag.Title = "Registrera mätarställning"; ViewBag.SubTitle = "Registrera aktuell mätarställning"; ViewBag.Action = "Registrera"; var now = DateTime.Now; var model = new RegisterEntryModel { DateString = $"{now.ToShortDateString()} {now.ToShortTimeString()}", RegisterValue = string.Empty, }; return(View(model)); }