public CategoryListPage() { InitializeComponent(); IsolatedStorageFile ISOFile = IsolatedStorageFile.GetUserStoreForApplication(); if (IsolatedStorageSettings.ApplicationSettings.Contains("islogin")) { if (!(Convert.ToString(IsolatedStorageSettings.ApplicationSettings["islogin"]).ToLower() == "yes")) { NavigationService.Navigate(new Uri("/Views/LoginPage.xaml", UriKind.RelativeOrAbsolute)); } else { if (ISOFile.FileExists("CurrentLoginUserDetails"))//read current user login details { using (IsolatedStorageFileStream fileStream = ISOFile.OpenFile("CurrentLoginUserDetails", FileMode.Open)) { DataContractSerializer serializer = new DataContractSerializer(typeof(LoginViewModel)); var ObjUserData = (LoginViewModel)serializer.ReadObject(fileStream); this.txtHeaderOrgName.Text = ObjUserData.organizationName; this.txtHeaderFullName.Text = ObjUserData.firstName + " " + ObjUserData.lastName; _employeeId = Convert.ToInt32(ObjUserData.employeeId); _organizationId = Convert.ToInt32(ObjUserData.organizationId); lstMenuItems.ItemsSource = Utilities.GetMenuItems(MenuCode.CatMngt); // Show Loader myIndeterminateProbar.Visibility = Visibility.Visible; //==================================================================================================================== // Fill Category List //==================================================================================================================== // Parameters CategoryRequest obj = new CategoryRequest(); obj.organizationId = _organizationId; obj.set = 1; obj.count = 5; String data = "organizationId=" + obj.organizationId + "&set=" + obj.set + "&count=" + obj.count; //Initialize WebClient WebClient webClient = new WebClient(); //Set Header webClient.Headers[HttpRequestHeader.Authorization] = Utilities.GetAuthorization(); webClient.Headers["Content-Type"] = "application/x-www-form-urlencoded"; webClient.Headers[HttpRequestHeader.AcceptLanguage] = "en_US"; webClient.UploadStringAsync(new Uri(Utilities.GetURL("category/categoryListing/")), "POST", data); //Assign Event Handler0 webClient.UploadStringCompleted += wc_UploadStringCompleted; } } } } else { NavigationService.Navigate(new Uri("/Views/LoginPage.xaml", UriKind.RelativeOrAbsolute)); } }
private void btnSave_Click(object sender, RoutedEventArgs e) { // Show Loader myIndeterminateProbar.Visibility = Visibility.Visible; // Parameters CategoryRequest obj = new CategoryRequest(); obj.organizationId = _organizationId; // Logged In organizationId obj.categoryCode = txtcategoryName.Text; obj.categoryDescription = txtcategoryDescription.Text; obj.parentCategoryId = 0; // 0 for category and category id for subcategory String data = string.Empty; if (Validation() == true) { //Initialize WebClient WebClient webClient = new WebClient(); //Set Header webClient.Headers[HttpRequestHeader.Authorization] = Utilities.GetAuthorization(); webClient.Headers["Content-Type"] = "application/x-www-form-urlencoded"; webClient.Headers[HttpRequestHeader.AcceptLanguage] = "en_US"; if (_mode == "Add") { data = "organizationId=" + obj.organizationId + "&categoryCode=" + obj.categoryCode + "&categoryDescription=" + obj.categoryDescription + "&parentCategoryId=" + obj.parentCategoryId ; webClient.UploadStringAsync(new Uri(Utilities.GetURL("category/addCategory/")), "POST", data); } if (_mode == "Edit") { obj.categoryId = _categoryId; data = "organizationId=" + obj.organizationId + "&categoryId=" + obj.categoryId + "&categoryCode=" + obj.categoryCode + "&categoryDescription=" + obj.categoryDescription + "&parentCategoryId=" + obj.parentCategoryId; webClient.UploadStringAsync(new Uri(Utilities.GetURL("category/updateCategory/")), "POST", data); } //Assign Event Handler webClient.UploadStringCompleted += wc_UploadSaveCompleted; } }