public async Task <bool> GetProfile(string userName, string password) { try { SQLiteHelper sqliteHelper = new SQLiteHelper(); bool result = false; var jsonLoginDetails = JsonConvert.SerializeObject(new { UserName = userName, Password = password }); var response = await RESTServiceHelper.PostData("/signin", jsonLoginDetails); ProfileViewModel profile = JsonConvert.DeserializeObject <ProfileViewModel>(response); if (profile != null) { profile.CanSaveAsNewUser = false; sqliteHelper.InsertUserProfile(profile); result = true; } return(result); } catch (Exception ex) { return(false); } }
public async Task <string> SaveProfile(ProfileViewModel userProfile) { try { SQLiteHelper sqliteHelper = new SQLiteHelper(); string result = string.Empty; var jsonProfileDetails = JsonConvert.SerializeObject( new { UserName = userProfile.UserName, Password = userProfile.Password, FirstName = userProfile.FirstName, LastName = userProfile.LastName, EmailId = userProfile.EmailId, DefaultLocation = userProfile.DefaultLocation, MobileNumber = userProfile.MobileNumber, ProfilePicture = userProfile.ProfilePicture }); string response = await RESTServiceHelper.PostData("/signup", jsonProfileDetails); if (response == "false") { return("Username already exists. Try with different username."); } ProfileViewModel profile = JsonConvert.DeserializeObject <ProfileViewModel>(response); if (profile != null) { profile.CanSaveAsNewUser = false; sqliteHelper.InsertUserProfile(profile); result = "true"; } return(result); } catch (Exception ex) { throw new Exception("Save profile failed..!!"); } }
public async Task <ObservableCollection <Item> > GetItems() { SQLiteHelper sqlHelper = new SQLiteHelper(); ProfileViewModel profile = sqlHelper.GetUserProfile(); var jsonFilterData = JsonConvert.SerializeObject( new { ItemType = "", Brand = "", Model = "", PartName = "", CustomerUserName = "", Location = profile.DefaultLocation }); string response = await RESTServiceHelper.PostData("/GetItems", jsonFilterData); var items = JsonConvert.DeserializeObject <ObservableCollection <Item> >(response); return(items); }