public ActionResult Create(WaveViewModel viewModel) { var request = viewModel.MapTo<SaveWaveRequest>(); _waveService.SaveWave(request); return RedirectToAction("Index"); }
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>(); 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; var resp = _waveService.SaveWave(request); return Json(resp); } }