private TwitterViewModel GetTwitterSetting(SettingViewModel setting) { TwitterViewModel twitter = null; if (setting.value != null) { twitter = JsonConvert.DeserializeObject<TwitterViewModel>(setting.value); } else { twitter = new TwitterViewModel() { id = setting.id, alias = setting.alias, name = setting.name }; } return twitter; }
public ActionResult EditTwitter(TwitterViewModel 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("Twitter"), 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("TwitterEdit", model); }