//[AuthorizeControllerWithToken("admin")] public IActionResult createEvent() { if (!authorize.AuthorizeUser("admin")) { return(RedirectToAction("login", "user")); } return(View()); }
public async Task <ActionResult> settings() { if (!authorize.AuthorizeUser()) { return(RedirectToAction("login", "user")); } String userId = HttpContext.Session.GetString("userId").ToString(); using (client) { client.DefaultRequestHeaders.Accept.Clear(); //HTTP Get HttpResponseMessage response = await client.GetAsync("api/profile/" + userId); if (response.IsSuccessStatusCode == true) { UserDto user = response.Content.ReadAsAsync <UserDto>().Result; AccountPrivacyDto privacyDto = null; HttpResponseMessage response2 = await client.GetAsync("api/profile/privacy/" + userId); if (response2.IsSuccessStatusCode == true) { privacyDto = response2.Content.ReadAsAsync <AccountPrivacyDto>().Result; } SettingViewMolde settingView = new SettingViewMolde() { user = user, privacy = privacyDto }; return(View(settingView)); } String result = await response.Content.ReadAsStringAsync(); //JObject json = JObject.Parse(result); // Add errors to model state the return return(View(result)); } }
public async Task <IActionResult> all() { if (!authorize.AuthorizeUser()) { return(RedirectToAction("login", "user")); } using (client) { client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.Accept.Clear(); //HTTP Get string userId = HttpContext.Session.GetString("userId"); HttpResponseMessage response = await client.GetAsync("api/allEvents/" + userId); if (response.IsSuccessStatusCode == true) { IEnumerable <EventDto> events = response.Content.ReadAsAsync <IEnumerable <EventDto> >().Result; return(View(events)); } return(Content("Some Internal Error Occur")); } }