public static async Task <bool> loginSubmit(string username, string password, string captcha) { Models.Preferences.Token token = App.PreferenceDatabase.GetToken(); if (token == null) { throw new Exceptions.SessionTimeoutException(); } Models.GeneralReturn <Models.Responses.UserLoginSubmit> result = await DataFetch.post <Models.Responses.UserLoginSubmit>(String.Format(urlUserLoginSubmit, urlBase, token.AccessToken), new Dictionary <string, string> { { "username", username }, { "password", password }, { "captcha", captcha } }); if (result.Status == 200) { if (result.Data.Success) { token.IsLoggedIn = true; token.ValidBefore = DateTime.Now.AddMinutes(39); App.PreferenceDatabase.SetToken(token); } else { App.PreferenceDatabase.RemoveToken(); } return(result.Data.Success); } else { throw new Exception(result.Return); } }
public static async Task <Models.Schedule> fetchCurrent(string token) { Models.GeneralReturn <Models.Schedule> result = await DataFetch.post <Models.Schedule>(String.Format(urlGetScheduleCurrent, urlBase, token), new Dictionary <string, string> { }); if (result.Status == 200) { return(result.Data); } else { throw new Exception(result.Return); } }
//gereral tra hang public GeneralReturn GeneralReturn(StorageJP model) { GeneralReturn result = new Models.GeneralReturn(); var returnDetails = db.ReturnDetails.Where(n => n.PackageReturn.AgencyId == model.AgencyId).Where(n => n.StoregeJPId == model.Id); if (returnDetails.Count() > 0) { var item = returnDetails.First(); result = new Models.GeneralReturn() { ReturnCode = item.PackageReturn.ReturnCode, Status = PackageStatus(item.PackageReturn.StatusId.Value, 6) }; } return(result); }
public static async Task <string> loginStartWithCaptcha() { Models.GeneralReturn <Models.Responses.UserLoginStart> result = await DataFetch.get <Models.Responses.UserLoginStart>(String.Format(urlUserLoginStart, urlBase)); if (result.Status == 200) { App.PreferenceDatabase.SetToken(new Models.Preferences.Token { AccessToken = result.Data.Token, ValidBefore = DateTime.Now.AddMinutes(8), IsLoggedIn = false }); return(result.Data.Captcha); } else { throw new Exception(result.Return); } }