public ActionResult UpdateInfraGSM(HighlightViewModel viewModel) { var existingHighlight = _highlightService.GetHighlightByPeriode(new GetHighlightRequest { Date = viewModel.Date, HighlightTypeId = viewModel.TypeId }); SaveHighlightRequest req = new SaveHighlightRequest(); req.PeriodeType = (PeriodeType)Enum.Parse(typeof(PeriodeType), viewModel.PeriodeType, true); req.Date = viewModel.Date.Value; req.TypeId = viewModel.TypeId; req.UserId = UserProfile().UserId; req.ControllerName = "Der Input Form"; req.ActionName = string.Format("Update Infra GSM HighlightType:{0}", viewModel.TypeId); if (existingHighlight.Id == 0) { req.Message = "{\"a\" : \"\",\"b\" : \"\",\"c\" : \"\",\"d\" : \"\" }"; } else { req.Message = existingHighlight.Message; req.Id = existingHighlight.Id; } dynamic jsonObj = JsonConvert.DeserializeObject(req.Message); jsonObj[viewModel.Property] = viewModel.Message; req.Message = JsonConvert.SerializeObject(jsonObj, Formatting.Indented); var resp = _highlightService.SaveHighlight(req); return(Json(resp)); }
public ActionResult View(int typeId, string periodeType) { var periodeTypeEnum = (PeriodeType)Enum.Parse(typeof(PeriodeType), periodeType); var date = DateTime.Now.Date; switch (periodeTypeEnum) { case PeriodeType.Monthly: date = new DateTime(date.Year, date.Month, 1); break; case PeriodeType.Yearly: date = new DateTime(date.Year, 1, 1); break; } var highlight = _highlightService.GetHighlightByPeriode(new GetHighlightRequest { Date = date, HighlightTypeId = typeId, PeriodeType = periodeTypeEnum }, true); var jsonResult = Json(highlight, JsonRequestBehavior.AllowGet); jsonResult.MaxJsonLength = int.MaxValue; return jsonResult; }