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>(); 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 virtual ActionResult Wave(int bucketId) { var bucket = _service.GetBucket(bucketId); if (bucket == null) { ModelState.AddModelError("bucketId", "Unrecognized Bucket."); return(RedirectToAction(Actions.Index())); } #region Storing Selected Vwh for activating the same tab next time var cookie = Request.Cookies[COOKIE_SELECTED_VWH]; if (cookie == null || cookie.Value != bucket.VwhId) { cookie = new HttpCookie(COOKIE_SELECTED_VWH, bucket.VwhId); } cookie.Expires = DateTime.Now.AddMinutes(60); // remember for one hour sliding this.Response.Cookies.Add(cookie); #endregion cookie = Request.Cookies[COOKIE_SELECTED_PRINTERS]; var model = new WaveViewModel { BucketId = bucketId, IsFrozen = bucket.IsFrozen, PrinterList = (from printer in _service.GetPrinterList(_buildingId) select new SelectListItem { Text = printer.Description, Value = printer.PrinterName, Selected = cookie != null && cookie.Values.AllKeys.Contains(printer.PrinterName) }).ToArray(), PrintedBoxCount = bucket.CountPrintedBoxes, TotalBoxes = bucket.TotalBoxes, BoxesNotInBatch = bucket.BoxesNotInBatch, PrintedBatchList = _service.GetBatches(bucketId).Select(Map).ToArray(), BatchSize = Request.Cookies[COOKIE_SELECTED_BATCH_SIZE] == null ? (int?)null : int.Parse(Request.Cookies[COOKIE_SELECTED_BATCH_SIZE].Value) }; return(View(Views.Wave, model)); }
public ActionResult Create() { var viewModel = new WaveViewModel(); foreach (var name in Enum.GetNames(typeof(PeriodeType))) { if (!name.Equals("Hourly") && !name.Equals("Weekly")) { viewModel.PeriodeTypes.Add(new SelectListItem { Text = name, Value = name }); } } viewModel.Values = _selectService.GetSelect(new GetSelectRequest { Name = "wave-values" }).Options .Select(x => new SelectListItem { Value = x.Id.ToString(), Text = x.Text }).ToList(); return(View(viewModel)); }