public override void Get(HttpRequest Request, HttpResponse Response, params string[] PathParams) { Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.Cache.SetMaxAge(TimeSpan.Zero); Response.ContentType = @"application/json"; Int64 product_id = Request.QueryString["product_id"] != null?Convert.ToInt64(Request.QueryString["product_id"]) : 0; using (StreamWriter streamWriter = new StreamWriter(Response.OutputStream)) { using (JsonTextWriter jsonWriter = new JsonTextWriter(streamWriter)) { ProductYad2 productYad2 = ProductYad2.FetchByID(product_id); if (productYad2 == null) { RespondNotFound(Response); } jsonWriter.WriteStartObject(); jsonWriter.WritePropertyName(@"price"); jsonWriter.WriteValue(productYad2.Price); jsonWriter.WritePropertyName(@"product_name"); jsonWriter.WriteValue(productYad2.ProductName ?? ""); jsonWriter.WritePropertyName(@"contact_name"); jsonWriter.WriteValue(productYad2.ContactName ?? ""); jsonWriter.WritePropertyName(@"description"); jsonWriter.WriteValue(productYad2.Details ?? ""); jsonWriter.WritePropertyName(@"product_image"); jsonWriter.WriteValue(productYad2.ProductImage ?? ""); jsonWriter.WritePropertyName(@"phone"); jsonWriter.WriteValue(productYad2.Phone ?? ""); jsonWriter.WritePropertyName(@"city_id"); jsonWriter.WriteValue(productYad2.CityId); jsonWriter.WritePropertyName(@"price_id"); jsonWriter.WriteValue(productYad2.PriceId); jsonWriter.WritePropertyName(@"status"); jsonWriter.WriteValue(Enum.GetName(typeof(StatusType), productYad2.Status).ToLower()); jsonWriter.WritePropertyName(@"list_category"); jsonWriter.WriteStartArray(); List <CategoryYad2> categoryYad2Col = ProductYad2Controller.GetAllCatagoriesOfProduct(product_id); foreach (CategoryYad2 item in categoryYad2Col) { jsonWriter.WriteStartObject(); jsonWriter.WritePropertyName(@"category_id"); jsonWriter.WriteValue(item.CategoryYad2Id); jsonWriter.WritePropertyName(@"category_name"); jsonWriter.WriteValue(item.CategoryYad2Name); jsonWriter.WriteEndObject(); } jsonWriter.WriteEndArray(); jsonWriter.WriteEndObject(); } } }
protected void LoadItems() { if (!HasEditPermission) { dgProductsYad2.Columns[dgProductsYad2.Columns.Count - 1].Visible = false; } List <int> StatusIdList = new List <int>(); //if (IsSearch) if (FillStatusList().Count > 0) { StatusIdList = FillStatusList(); } dgProductsYad2.VirtualItemCount = ProductYad2Controller.GetAllProductsYad2(StatusIdList).Count; if (dgProductsYad2.VirtualItemCount == 0) { phHasNoItems.Visible = true; phHasItems.Visible = false; } else { phHasNoItems.Visible = false; phHasItems.Visible = true; if (dgProductsYad2.PageSize * dgProductsYad2.CurrentPageIndex > dgProductsYad2.VirtualItemCount) { dgProductsYad2.CurrentPageIndex = 0; hfCurrentPageIndex_dgProductsYad2.Value = dgProductsYad2.CurrentPageIndex.ToString(); } List <ProductYad2UI> productsYad2 = ProductYad2Controller.GetAllProductsYad2(StatusIdList, dgProductsYad2.PageSize, dgProductsYad2.CurrentPageIndex); BindList(productsYad2); } }
protected void btnApprove_Click(object sender, EventArgs e) { ProductYad2Controller.ApproveProduct(Int64.Parse(hiddenFieldProductId.Value), txtStatusRemarks.Text, string.Format(Snoopi.web.Localization.PushStrings.GetText("PushYad2Accepted"))); string url = @"ProductsYad2.aspx"; Response.Redirect(url, true); }
protected void btnExport_Click(object sender, EventArgs e) { System.Data.DataTable dt = new System.Data.DataTable(); dt.Columns.Add(new System.Data.DataColumn(Yad2Strings.GetText(@"ProductName"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(Yad2Strings.GetText(@"LstCategory"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(Yad2Strings.GetText(@"Price"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(Yad2Strings.GetText(@"CityName"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(Yad2Strings.GetText(@"ContactName"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(Yad2Strings.GetText(@"Phone"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(Yad2Strings.GetText(@"Details"), typeof(string))); dt.Columns.Add(new System.Data.DataColumn(Yad2Strings.GetText(@"Status"), typeof(string))); List <int> StatusIdList = FillStatusList(); List <ProductYad2UI> productsYad2 = ProductYad2Controller.GetAllProductsYad2(StatusIdList); foreach (ProductYad2UI product in productsYad2) { System.Data.DataRow row = dt.NewRow(); row[0] = product.ProductName; row[1] = (product.LstCategory.Count == 0 || product.LstCategory == null) ? "" : String.Join(", ", product.LstCategory.Select(p => p.CategoryYad2Name)); row[2] = product.Price; row[3] = product.CityName; row[4] = product.ContactName; row[5] = "\"" + product.Phone + "\""; row[6] = product.Details; row[7] = Yad2Strings.GetText(Enum.GetName(typeof(StatusType), product.Status)); dt.Rows.Add(row); } System.Data.DataRow sumRow = dt.NewRow(); sumRow[0] = Yad2Strings.GetText(@"SumPrice") + " " + productsYad2.Sum(p => p.Price); dt.Rows.Add(sumRow); SpreadsheetWriter ex = SpreadsheetWriter.FromDataTable(dt, false, true); Response.Clear(); Response.AddHeader(@"content-disposition", @"attachment;filename=ProductsYad2Export_" + DateTime.UtcNow.ToString(@"yyyy_MM_dd_HH_mm_ss") + "." + ex.FileExtension); Response.Charset = @"UTF-8"; Response.ContentEncoding = System.Text.Encoding.UTF8; Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.ContentType = ex.FileContentType; Response.BinaryWrite(System.Text.Encoding.UTF8.GetPreamble()); Response.Write(ex.ToString()); Response.End(); }
public override void Get(HttpRequest Request, HttpResponse Response, params string[] PathParams) { Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.Cache.SetMaxAge(TimeSpan.Zero); try { Int64 AppUserId; if (IsAuthorizedRequest(Request, Response, true, out AppUserId)) { Response.ContentType = @"application/json"; using (StreamWriter streamWriter = new StreamWriter(Response.OutputStream)) { using (JsonTextWriter jsonWriter = new JsonTextWriter(streamWriter)) { ProductYad2Collection productYad2Col = ProductYad2Controller.GetAllProductByAppUserId(AppUserId); jsonWriter.WriteStartObject(); jsonWriter.WritePropertyName(@"products"); jsonWriter.WriteStartArray(); foreach (ProductYad2 productYad2 in productYad2Col) { jsonWriter.WriteStartObject(); jsonWriter.WritePropertyName(@"product_id"); jsonWriter.WriteValue(productYad2.ProductId); jsonWriter.WritePropertyName(@"product_name"); jsonWriter.WriteValue(productYad2.ProductName ?? ""); jsonWriter.WritePropertyName(@"product_date"); jsonWriter.WriteValue(productYad2.UpdateDate.ToShortDateString()); jsonWriter.WritePropertyName(@"status"); jsonWriter.WriteValue(Enum.GetName(typeof(StatusType), productYad2.Status).ToLower()); jsonWriter.WriteEndObject(); } jsonWriter.WriteEndArray(); jsonWriter.WriteEndObject(); } } } } catch (Exception) { } }
public override void Get(HttpRequest Request, HttpResponse Response, params string[] PathParams) { Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.Cache.SetMaxAge(TimeSpan.Zero); try { Response.ContentType = @"application/json"; using (StreamWriter streamWriter = new StreamWriter(Response.OutputStream)) { using (JsonTextWriter jsonWriter = new JsonTextWriter(streamWriter)) { List <ProductYad2UI> productYad2Col = ProductYad2Controller.GetAllProduct(); jsonWriter.WriteStartObject(); jsonWriter.WritePropertyName(@"products"); jsonWriter.WriteStartArray(); foreach (ProductYad2UI productYad2 in productYad2Col) { jsonWriter.WriteStartObject(); jsonWriter.WritePropertyName(@"product_id"); jsonWriter.WriteValue(productYad2.ProductYad2.ProductId); jsonWriter.WritePropertyName(@"price"); jsonWriter.WriteValue(productYad2.ProductYad2.Price); jsonWriter.WritePropertyName(@"product_name"); jsonWriter.WriteValue(productYad2.ProductYad2.ProductName ?? ""); jsonWriter.WritePropertyName(@"product_image"); jsonWriter.WriteValue(productYad2.ProductYad2.ProductImage ?? ""); jsonWriter.WritePropertyName(@"city_id"); jsonWriter.WriteValue(productYad2.ProductYad2.CityId); jsonWriter.WritePropertyName(@"price_id"); jsonWriter.WriteValue(productYad2.ProductYad2.PriceId); jsonWriter.WritePropertyName(@"product_date"); jsonWriter.WriteValue(productYad2.ProductYad2.UpdateDate.ToShortDateString()); jsonWriter.WritePropertyName(@"description"); jsonWriter.WriteValue(productYad2.ProductYad2.Details); jsonWriter.WritePropertyName(@"contact_name"); jsonWriter.WriteValue(productYad2.ProductYad2.ContactName ?? ""); jsonWriter.WritePropertyName(@"phone"); jsonWriter.WriteValue(productYad2.ProductYad2.Phone); jsonWriter.WritePropertyName(@"product_date"); jsonWriter.WriteValue(productYad2.ProductYad2.UpdateDate.ToShortDateString()); jsonWriter.WritePropertyName(@"list_category"); jsonWriter.WriteStartArray(); foreach (CategoryYad2 item in productYad2.LstCategory) { jsonWriter.WriteStartObject(); jsonWriter.WritePropertyName(@"category_id"); jsonWriter.WriteValue(item.CategoryYad2Id); jsonWriter.WriteEndObject(); } jsonWriter.WriteEndArray(); jsonWriter.WriteEndObject(); } jsonWriter.WriteEndArray(); jsonWriter.WriteEndObject(); } } } catch (Exception) { } }