public ActionResult UpdateWave(WaveViewModel viewModel) { var wave = _waveService.GetWave(new GetWaveRequest { Date = viewModel.Date, ByDate = true }); if (wave.Id == 0) { var request = viewModel.MapTo <SaveWaveRequest>(); request.UserId = UserProfile().UserId; request.ControllerName = "Der Input Form"; request.ActionName = "Insert Wave"; var resp = _waveService.SaveWave(request); return(Json(resp)); } else { var request = viewModel.MapTo <SaveWaveRequest>(); request.Id = wave.Id; request.Tide = viewModel.Property == "tide" ? viewModel.Tide : wave.Tide; request.ValueId = viewModel.Property == "wind-direction" ? viewModel.ValueId : wave.ValueId; request.Speed = viewModel.Property == "speed" ? viewModel.Speed : wave.Speed; request.UserId = UserProfile().UserId; request.ControllerName = "Der Input Form"; request.ActionName = "Update Wave"; var resp = _waveService.SaveWave(request); return(Json(resp)); } }
public ActionResult Create(WaveViewModel viewModel) { var request = viewModel.MapTo <SaveWaveRequest>(); _waveService.SaveWave(request); return(RedirectToAction("Index")); }