public async Task <IActionResult> Edit(int Id) { await LoadDdl(); var taskModelView = await AdminHttpClient.GetAsync <TaskModelView>(WebConfiguration.Instance.WebApiConfig, $"api/Task/{Id}", Request) ?? new TaskModelView(); return(View(taskModelView)); }
public async Task <IActionResult> Index() { var response = await AdminHttpClient.GetAsync(WebConfiguration.Instance.WebApiConfig, "api/Registration", Request); if (response.IsSuccessStatusCode) { var list = await response.Content.ReadAsAsync <List <RegistrationModelView> >() ?? new List <RegistrationModelView>(); return(View(list)); } return(View(new List <RegistrationModelView>())); }
public async Task <IActionResult> Index() { int userId = currentUser.Id; var response = await AdminHttpClient.GetAsync(WebConfiguration.Instance.WebApiConfig, $"api/Task?assainedId={userId}", Request); if (response.IsSuccessStatusCode) { var list = await response.Content.ReadAsAsync <List <TaskModelView> >() ?? new List <TaskModelView>(); return(View(list)); } return(View(new List <TaskModelView>())); }
public async Task <IActionResult> SignIn(UserCredentialViewModel userCredentialViewModel) { if (User.Identity.IsAuthenticated) { return(RedirectToAction("Index")); } if (!ModelState.IsValid) { return(RedirectToAction("Login", "Home")); } var response = await AdminHttpClient.PostAsync(WebConfiguration.Instance.WebApiConfig, "api/Auth/Login", userCredentialViewModel, Request); if (!response.IsSuccessStatusCode) { return(RedirectToAction("Login", "Home", "", "LoginFail")); } var credential = await response.Content.ReadAsAsync <UserCredentialViewModel>(); CookieOptions cookieOptions = new CookieOptions { Path = "/", Expires = DateTime.Now.AddHours(5), SameSite = SameSiteMode.Strict, IsEssential = true }; var val = credential.Token; Response.Cookies.Append(ConfigKeys.AuthCookieKey, val, cookieOptions); var model = await AdminHttpClient.GetAsync <RegistrationModelView>(WebConfiguration.Instance.WebApiConfig, $"api/Registration/{userCredentialViewModel.UserName}/token", credential.Token); if (model != null) { val = HttpUtility.UrlEncode(JsonConvert.SerializeObject( new { FullName = model.FirstLastName, model.Email, model.Id, model.MobileNumber }, Formatting.None)); Response.Cookies.Append(ConfigKeys.UserCookieKey, val, cookieOptions); } return(RedirectToAction("Index", "Home")); }
private async Task LoadDdl() { var lsituser = await AdminHttpClient.GetAsync <List <RegistrationModelView> >(WebConfiguration.Instance.WebApiConfig, $"api/Registration", Request) ?? new List <RegistrationModelView>(); ViewBag.users = lsituser; }