private FacebookViewModel GetFBSetting(SettingViewModel setting) { FacebookViewModel fb = null; if (setting.value != null) { fb = JsonConvert.DeserializeObject<FacebookViewModel>(setting.value); } else { fb = new FacebookViewModel() { id = setting.id, alias = setting.alias, name = setting.name }; } return fb; }
public ActionResult EditFB(FacebookViewModel model) { try { if (ModelState.IsValid) { SetRequestURL(APIURL.SETTINGS_UPDATE, Method.POST); request.AddBody(new SettingViewModel() { id = model.id, name = model.name, alias = model.alias, value = JsonConvert.SerializeObject(model) }); var response = rest.Execute(request); if (response.StatusCode == HttpStatusCode.OK) { SetMessage(Message.SuccessfulUpdate("Facebook"), MESSAGE_TYPE.SUCCESS); return RedirectToAction("Details", new { alias = model.alias }); } else { ModelState.AddModelError("", response.Content); } } } catch (Exception ex) { ModelState.AddModelError("", ex.Message); } SetTitle("Edit - " + model.name); return View("FacebookEdit", model); }