protected void btnAdd_Click(object sender, EventArgs e) { try { //Save the file on server's folder kepping the original filename flImageUpload.SaveAs(Server.MapPath(@"~\Site_data\product_images\" + flImageUpload.FileName)); Product pr = new Product { ProductName = txtName.Text, ProductDescription = txtDescription.Text, ProductPrice = Convert.ToDecimal(txtPrice.Text), ProductImageURL = @"~\Site_data\product_images\" + flImageUpload.FileName, Discount = Convert.ToInt16(string.IsNullOrEmpty(txtDiscount.Text) ? "0" : txtDiscount.Text), CategoryID = Convert.ToInt16(ddlCategory.SelectedValue) }; using (ecommerceEntities context = new ecommerceEntities()) { context.Products.Add(pr); context.SaveChanges(); } lblStatus.Text = "Product successfully uploaded."; lblStatus.ForeColor = System.Drawing.Color.Green; hlAddFeature.NavigateUrl = "~/Admin/addFeatures.aspx?ProductID=" + pr.ProductID; } catch (System.IO.DirectoryNotFoundException ex) { lblStatus.ForeColor = System.Drawing.Color.Red; lblStatus.Text = "Select an image first"; } }
protected void btnPrev_Click(object sender, EventArgs e) { //Enable next button if it's disabled. if (btnNext.Enabled == false) { btnNext.Enabled = true; } using (ecommerceEntities context = new ecommerceEntities()) { List <Product> pr = context.Products.Where(p => p.CategoryID == 1).ToList(); int i = (int)ViewState["rowMobile"]; //Get the next rowMobile i--; try { lblPrice.Text = pr[i].ProductPrice.ToString(); lnkProductTitle.Text = pr[i].ProductName; lnkProductTitle.NavigateUrl = "product.aspx?ProductID=" + pr[i].ProductID; lnkImageLinkTo.NavigateUrl = lnkProductTitle.NavigateUrl; imgProduct.ImageUrl = pr[i].ProductImageURL; lnkOrder.NavigateUrl = lnkProductTitle.NavigateUrl; } catch (ArgumentOutOfRangeException ex) { //There aren't anymore rowMobiles so, disable further action. btnPrev.Enabled = false; i++; } //Updating viewstate for next use. ViewState["rowMobile"] = i; } }
public IHttpActionResult PostAddNewProduct(ProductDTO product) { if (product == null) { return(BadRequest("Invalid data")); } try { using (var ctx = new ecommerceEntities()) { ctx.Products.Add(new Product() { Name = product.Name, Price = product.Price, Description = product.Description, UnitInStock = product.UnitInStock }); ctx.SaveChanges(); } } catch (Exception ex) { return(BadRequest("Invalid data")); } return(Ok()); }
protected void btnPasswordRecover_Click(object sender, EventArgs e) { using (ecommerceEntities context = new ecommerceEntities()) { Customer cust = context.Customers.Where(i => i.email == txtEmail.Text).FirstOrDefault(); if (cust == null) { string title = "User ID not found"; string message = "No user found with the given email ID. Please provide the email ID you signed up with."; string jsFunction = string.Format("showNotification('{0}','{1}')", title, message); ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "notify", jsFunction, true); } else { string email = cust.email; string password = cust.Password; MailMessage mail = new MailMessage("*****@*****.**", email); mail.Subject = "Password for your eCommerce ID"; mail.Body = "Your password for eCommerce is : " + password; mail.IsBodyHtml = false; SmtpClient smp = new SmtpClient(); //smp.Send(mail); string title = "Password sent!"; string message = "Your password has been sent to " + email; string jsFunction = string.Format("showNotification('{0}','{1}')", title, message); ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "notify", jsFunction, true); } } }
protected void btnPost_Click(object sender, EventArgs e) { using (ecommerceEntities context = new ecommerceEntities()) { if (Session["CustomerID"] != null) { int CustID = Convert.ToInt16(Session["CustomerID"].ToString()); int ProdID = Convert.ToInt16(Request.QueryString["ProductID"]); Review rv = new Review() { ReviewTitle = txtReviewTitle.Text, ReviewDescription = txtReviewDetail.Text, CustomerID = CustID, ProductID = ProdID, Rating = Convert.ToInt16(ddlRatings.SelectedValue), ReviewDate = DateTime.Now }; context.Reviews.Add(rv); context.SaveChanges(); string notifyTitle = "Review added"; string message = "Your review has been posted on the product page. Thanks for helping others."; string notification = string.Format("?notifyTitle={0}¬ificationDescription={1}", notifyTitle, message); Response.Redirect("~/product.aspx?ProductID=" + ViewState["prodid"].ToString() + "&" + notification); } } }
protected void Page_Load(object sender, EventArgs e) { if (Session["CustomerID"] == null) { Response.Redirect("login.aspx"); } else { if (!IsPostBack) { using (ecommerceEntities context = new ecommerceEntities()) { //Getting user info based on session variable int id = (int)Session["CustomerID"]; Customer cust = context.Customers.Where(i => i.CustomerID == id).FirstOrDefault(); //Setting page title. Page.Title = "Profile | " + cust.CustomerName; //Setting values from DB txtName.Text = cust.CustomerName; txtUserName.Text = cust.UserName; txtContact.Text = cust.ContactNumber; ddlGender.SelectedValue = cust.sex; txtEmail.Text = cust.email; txtAddress.Text = cust.Address; } } } }
public IHttpActionResult DeleteProductById(int id) { if (!ModelState.IsValid) { return(BadRequest("Invalid data")); } try { using (var ctx = new ecommerceEntities()) { var prodructItem = ctx.Products.Where(x => x.ID == id).FirstOrDefault(); if (prodructItem != null) { ctx.Products.Remove(prodructItem); ctx.SaveChanges(); } else { return(BadRequest("Invalid data")); } } } catch (Exception ex) { return(BadRequest("Invalid data")); } return(Ok()); }
public IHttpActionResult GetProduct(int id) { if (!ModelState.IsValid) { return(BadRequest("Invalid data")); } try { using (var ctx = new ecommerceEntities()) { var prodructItem = ctx.Products.Where(x => x.ID == id).FirstOrDefault(); if (prodructItem != null) { ProductDTO product = new ProductDTO(); product.ID = prodructItem.ID; product.Name = prodructItem.Name; product.Price = prodructItem.Price; product.Description = prodructItem.Description; product.UnitInStock = prodructItem.UnitInStock; return(Ok(product)); } else { return(BadRequest("Invalid data")); } } } catch (Exception ex) { return(BadRequest("Invalid data")); } }
protected void btnClothesNext_Click(object sender, EventArgs e) { //Enable prev button if it's disabled. if (btnClothesPrev.Enabled == false) { btnClothesPrev.Enabled = true; } using (ecommerceEntities context = new ecommerceEntities()) { List <Product> clothes = context.Products.Where(p => p.CategoryID == 3).ToList(); int i = (int)ViewState["rowClothes"]; //Get the next row i++; try { lblClothesPrice.Text = clothes[i].ProductPrice.ToString(); lnkClothesTitle.Text = clothes[i].ProductName; lnkClothesTitle.NavigateUrl = "product.aspx?ProductID=" + clothes[i].ProductID; lnkImageLinkToClothes.NavigateUrl = lnkClothesTitle.NavigateUrl; imgProductClothes.ImageUrl = clothes[i].ProductImageURL; lnkClothesOrder.NavigateUrl = lnkClothesTitle.NavigateUrl; } catch (ArgumentOutOfRangeException ex) { //There aren't anymore rows so, disable further action. btnClothesNext.Enabled = false; i--; } //Updating viewstate for next use. ViewState["rowClothes"] = i; } }
public IHttpActionResult PostAddOrder([FromBody] int productId) { if (!ModelState.IsValid) { return(BadRequest("Invalid data")); } try { using (var ctx = new ecommerceEntities()) { var productItem = ctx.Products.Where(x => x.ID == productId).FirstOrDefault(); if (productItem != null && productItem.UnitInStock > 0) { ctx.Orders.Add(new Order() { ProductID = productId, Quantity = 1, TotalAmount = 1 * productItem.Price, Date = DateTime.Now }); productItem.UnitInStock = productItem.UnitInStock - 1; ctx.SaveChanges(); } else { return(BadRequest("The product is not available")); } } } catch (Exception ex) { return(BadRequest("Invalid data")); } return(Ok()); }
public IHttpActionResult GetOrderById(int id) { if (!ModelState.IsValid) { return(BadRequest("Invalid data")); } try { using (var ctx = new ecommerceEntities()) { var orderItem = ctx.Orders.Where(x => x.ID == id).FirstOrDefault(); var prodructItem = ctx.Products.Where(x => x.ID == orderItem.ProductID).FirstOrDefault(); if (orderItem != null) { OrderDTO order = new OrderDTO(); order.ID = orderItem.ID; order.ProductID = orderItem.ProductID; order.ProductName = prodructItem.Name; order.Quantity = orderItem.Quantity; order.TotalAmount = orderItem.TotalAmount; return(Ok(order)); } else { return(BadRequest("Invalid data")); } } } catch (Exception ex) { return(BadRequest("Invalid data")); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //Get the lookup string form URL string lookup = Request.QueryString["product"]; string category = Request.QueryString["category"]; Page.Title = "Search: " + lookup; //Keeping the lookup string in searchbar for ease of use ((TextBox)this.Page.Master.FindControl("txtSearch")).Text = lookup; using (ecommerceEntities context = new ecommerceEntities()) { //Running %like query on 2 fields to get best results from DB List <Product> pr = context.Products.Where(i => i.ProductName.Contains(lookup) || i.ProductDescription.Contains(lookup) ).ToList(); var lq = (from p in context.Products join c in context.Categories on p.CategoryID equals c.CategoryID where (string.IsNullOrEmpty(category) ? true : c.CategoryName == category) && (string.IsNullOrEmpty(lookup)? true : p.ProductName.Contains(lookup) || p.ProductDescription.Contains(lookup)) select p).ToList(); Repeater1.DataSource = lq; Repeater1.DataBind(); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //Populating Mobile category //Instantiating the entity class to access DB tables using (ecommerceEntities context = new ecommerceEntities()) { //Query the DB for products which are mobile i.e. CategoryID == 1 List <Product> pr = context.Products.Where(i => i.CategoryID == 1).ToList(); //At first launch, fill fields with first rowMobile i.e. pr[0] lblPrice.Text = pr[0].ProductPrice.ToString(); lnkProductTitle.Text = pr[0].ProductName; lnkProductTitle.NavigateUrl = "product.aspx?ProductID=" + pr[0].ProductID; lnkImageLinkTo.NavigateUrl = lnkProductTitle.NavigateUrl; imgProduct.ImageUrl = pr[0].ProductImageURL; lnkOrder.NavigateUrl = lnkProductTitle.NavigateUrl; //Store returned rowMobile in viewstate for it to persist, to be used later. ViewState["rowMobile"] = 0; //Populating Books category //Query the DB for products which are books i.e. CategoryID == 4 List <Product> books = context.Products.Where(i => i.CategoryID == 4).ToList(); //At first launch, fill fields with first row i.e. pr[0] lblBookPrice.Text = books[0].ProductPrice.ToString(); lnkBookTitle.Text = books[0].ProductName; lnkBookTitle.NavigateUrl = "product.aspx?ProductID=" + books[0].ProductID; lnkImageLinkToBook.NavigateUrl = lnkBookTitle.NavigateUrl; imgProductBook.ImageUrl = books[0].ProductImageURL; lnkBookOrder.NavigateUrl = lnkBookTitle.NavigateUrl; //Store returned rowBook in viewstate for it to persist, to be used later. ViewState["rowBooks"] = 0; //Populating Clothes category //Query the DB for products which are clothes i.e. CategoryID == 3 List <Product> clothes = context.Products.Where(i => i.CategoryID == 3).ToList(); //At first launch, fill fields with first row i.e. pr[0] lblClothesPrice.Text = clothes[0].ProductPrice.ToString(); lnkClothesTitle.Text = clothes[0].ProductName; lnkClothesTitle.NavigateUrl = "product.aspx?ProductID=" + clothes[0].ProductID; lnkImageLinkToClothes.NavigateUrl = lnkClothesTitle.NavigateUrl; imgProductClothes.ImageUrl = clothes[0].ProductImageURL; lnkClothesOrder.NavigateUrl = lnkClothesTitle.NavigateUrl; //Store returned rowBook in viewstate for it to persist, to be used later. ViewState["rowClothes"] = 0; } } }
protected void btnChange_Click(object sender, EventArgs e) { using (ecommerceEntities context = new ecommerceEntities()) { //Getting user info based on session variable int id = (int)Session["CustomerID"]; Customer cust = context.Customers.Where(i => i.CustomerID == id).FirstOrDefault(); cust.Password = txtPassword.Text; context.SaveChanges(); } lblError.Visible = true; lblError.Text = "Password successfully updated"; }
public IHttpActionResult GETAllProducts() { List <Product> products = null; using (var ctx = new ecommerceEntities()) { products = ctx.Products.ToList(); } if (products == null) { return(NotFound()); } return(Ok(products)); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { using (ecommerceEntities context = new ecommerceEntities()) { List <Category> ct = context.Categories.ToList(); ddlCategory.DataSource = ct; ddlCategory.DataTextField = "CategoryName"; ddlCategory.DataValueField = "CategoryID"; ddlCategory.DataBind(); } } }
public IHttpActionResult PutOrderById(int id, OrderDTO order) { if (!ModelState.IsValid) { return(BadRequest("Invalid data")); } try { using (var ctx = new ecommerceEntities()) { var orderItem = ctx.Orders.Where(x => x.ID == order.ID).FirstOrDefault(); var productItem = ctx.Products.Where(x => x.ID == order.ProductID).FirstOrDefault(); if (productItem != null) { if (orderItem.Quantity != order.Quantity) { if (order.Quantity > orderItem.Quantity && productItem.UnitInStock >= (order.Quantity - orderItem.Quantity)) { productItem.UnitInStock = productItem.UnitInStock - (order.Quantity - orderItem.Quantity); } else if (order.Quantity < orderItem.Quantity) { productItem.UnitInStock = productItem.UnitInStock - (order.Quantity - orderItem.Quantity); } else { return(BadRequest("Insufficient Count")); } orderItem.Quantity = order.Quantity; orderItem.TotalAmount = productItem.Price * order.Quantity; orderItem.Date = order.Date; ctx.SaveChanges(); } else { return(BadRequest("No change in order count")); } } else { return(BadRequest("Invalid data")); } } } catch (Exception ex) { return(BadRequest("Invalid data")); } return(Ok()); }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["notifyTitle"] != null || Request.QueryString["notificationDescription"] != null) { string title = Request.QueryString["notifyTitle"]; string message = Request.QueryString["notificationDescription"]; string jsFunction = string.Format("showNotification('{0}','{1}')", title, message); ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "notify", jsFunction, true); } using (ecommerceEntities context = new ecommerceEntities()) { //Check if some user is logged in. if (Session["CustomerID"] != null) { //Getting user info based on session variable int id = (int)Session["CustomerID"]; Customer cust = context.Customers.Where(i => i.CustomerID == id).FirstOrDefault(); //Change the links lnkLogInLogOut.Text = "Logout"; lnkLogInLogOut.PostBackUrl = "logout.aspx"; lnkSignUpProfile.Text = "Welcome: " + cust.CustomerName; lnkSignUpProfile.PostBackUrl = "~/profile.aspx?CustomerID=" + cust.CustomerID; //Update Cart count var cart = (from c in context.ProductOrderStatus join p in context.Products on c.ProductId equals p.ProductID where c.CustomerId == id && c.StatusId == 1//in cart select new { p.ProductName, p.ProductPrice, p.ProductImageURL }); lblCartCount.Text = cart.Count().ToString(); var Wish = (from c in context.ProductOrderStatus join p in context.Products on c.ProductId equals p.ProductID where c.CustomerId == id && c.StatusId == 3//in wish select new { p.ProductName, p.ProductPrice, p.ProductImageURL }); lblWishCount.Text = Wish.Count().ToString(); var PlacedOrder = (from c in context.ProductOrderStatus join p in context.Products on c.ProductId equals p.ProductID where c.CustomerId == id && c.StatusId == 2//Placed Order select new { p.ProductName, p.ProductPrice, p.ProductImageURL }); lblPlaceOrder.Text = PlacedOrder.Count().ToString(); divUserList.Visible = true; } } }
private bool AddProducts(int CustID, int StatusId, ecommerceEntities context) { var cart = (from c in context.ProductOrderStatus join p in context.Products on c.ProductId equals p.ProductID where c.CustomerId == CustID && c.StatusId == StatusId//In Cart select new { p.ProductName, p.ProductPrice, p.ProductImageURL, c.ProductOrderStatusId }).ToList(); Repeater1.DataSource = cart; Repeater1.DataBind(); Boolean isCartEmpty = context.ProductOrderStatus.Where(i => i.CustomerId == CustID && i.StatusId == StatusId).FirstOrDefault() == null; return(isCartEmpty); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int id = Convert.ToInt16(Request.QueryString["ProductID"]); ViewState["prodid"] = id; using (ecommerceEntities context = new ecommerceEntities()) { if (Session["CustomerID"] == null) { Panel1.Enabled = false; } Product pr = context.Products.Where(i => i.ProductID == id).FirstOrDefault(); lblName.Text = pr.ProductName; lblPrice.Text += pr.ProductPrice.ToString(); lblDescription.Text = pr.ProductDescription; imgProductImage.ImageUrl = pr.ProductImageURL; //Setting page title Page.Title = pr.ProductName; //Joing feature tables to show data on datagrid var lq = (from f in context.Features join mf in context.MetaFeatures on f.MetaFeatureID equals mf.MetaFeatureID where f.ProductID == id select new { Feature = mf.FeatureName, Description = f.FeatureDescription }).ToList(); GridView1.DataSource = lq; GridView1.DataBind(); //Populating reviews var review = (from r in context.Reviews where r.ProductID == id join c in context.Customers on r.CustomerID equals c.CustomerID select new { r.ReviewDate, r.ReviewTitle, r.ReviewDescription, r.Rating, c.CustomerName }).ToList(); Repeater1.DataSource = review; Repeater1.DataBind(); } } }
protected void Page_Load(object sender, EventArgs e) { if (Session["CustomerID"] == null) { string redirectToURL = "~/order.aspx"; Response.Redirect("~/login.aspx?redirect=" + redirectToURL); } if (!IsPostBack) { //Get logged in id int CustID = Convert.ToInt16(Session["CustomerID"]); using (ecommerceEntities context = new ecommerceEntities()) { if (Request.QueryString["addToCart"] != null) { if (Request.QueryString["addToCart"] != "1") { ProductOrderStatus(CustID, 1, 1 /*Cart*/, context, "addToCart"); } bool isCartEmpty = AddProducts(CustID, 1, context); //If cart is empty. No ID label means, no cart item if (isCartEmpty) { Wizard1.Visible = false; lblMessage.Visible = true; } } else if (Request.QueryString["addToWishlist"] != null) { if (Request.QueryString["addToWishlist"] != "1") { ProductOrderStatus(CustID, 1, 3, context, "addToWishlist"); } bool isCartEmpty = AddProducts(CustID, 3 /*Wish*/, context); //If cart is empty. No ID label means, no cart item if (isCartEmpty) { Wizard1.Visible = false; lblMessage.Visible = true; } } } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { txtProductID.Text = Request.QueryString["ProductID"]; //Fill the list from table using (ecommerceEntities context = new ecommerceEntities()) { List <MetaFeature> mf = context.MetaFeatures.ToList(); ddlFeatureName.DataSource = mf; ddlFeatureName.DataTextField = "FeatureName"; ddlFeatureName.DataValueField = "MetaFeatureID"; ddlFeatureName.DataBind(); } } }
protected void Button1_Click(object sender, EventArgs e) { int CustID = Convert.ToInt16(Session["CustomerID"]); using (ecommerceEntities context = new ecommerceEntities()) { List <ProductOrderStatu> cr = context.ProductOrderStatus.Where(i => i.CustomerId == CustID && i.StatusId == 1).ToList(); foreach (ProductOrderStatu order in cr) { order.StatusId = 2; } context.SaveChanges(); Response.Redirect("~/ProductCollection.aspx?PlaceorderList=1"); } }
protected void btnSave_Click(object sender, EventArgs e) { using (ecommerceEntities context = new ecommerceEntities()) { Customer cust = context.Customers.Where(i => i.UserName == txtUserName.Text).FirstOrDefault(); cust.CustomerName = txtName.Text; cust.email = txtEmail.Text; cust.ContactNumber = txtContact.Text; cust.Address = txtAddress.Text; cust.Password = txtPassword.Text; cust.sex = ddlGender.SelectedValue; cust.UserType = ddlUserType.SelectedValue; context.SaveChanges(); } }
protected void Page_Load(object sender, EventArgs e) { using (ecommerceEntities context = new ecommerceEntities()) { var lq = (from o in context.Orders join p in context.Products on o.ProductID equals p.ProductID select new { o.OrderID, o.DateOrdered, p.ProductName, p.ProductPrice, p.Discount, }).ToList(); GridView1.DataSource = lq; GridView1.DataBind(); } }
protected void lnkRemoveItem_Click(object sender, EventArgs e) { using (ecommerceEntities context = new ecommerceEntities()) { string pagemode = Session["PageMode"].ToString(); int Status = 1; if (pagemode == "addToWishlist") { Status = 3; } else { Status = 1; } //Get the reference of the clicked button. LinkButton button = (sender as LinkButton); //Get the Repeater Item reference RepeaterItem item = button.NamingContainer as RepeaterItem; //Get the repeater item index int index = item.ItemIndex; string id = ((Label)(Repeater1.Items[index].FindControl("lblHiddenCartID"))).Text; int cartid = Convert.ToInt16(id); ProductOrderStatu cr = context.ProductOrderStatus.Where(i => i.ProductOrderStatusId == cartid && i.StatusId == Status).FirstOrDefault(); context.ProductOrderStatus.Remove(cr); context.SaveChanges(); string notifyTitle = "One item removed"; string message = "One item was removed from your "; if (Status == 1) { message = message + "cart!"; } else { message = message + "wish list!"; } string notification = string.Format("?notifyTitle={0}¬ificationDescription={1}", notifyTitle, message); Response.Redirect("~/ProductCollection.aspx" + notification); } }
public IHttpActionResult PostNewOrder(OrderDTO order) { if (!ModelState.IsValid) { return(BadRequest("Invalid data")); } try { using (var ctx = new ecommerceEntities()) { var orderItem = ctx.Orders.Where(x => x.ID == order.ID).FirstOrDefault(); var productItem = ctx.Products.Where(x => x.ID == order.ProductID).FirstOrDefault(); if (productItem != null) { if (order.Quantity <= productItem.UnitInStock) { ctx.Orders.Add(new Order() { ProductID = order.ProductID, Quantity = order.Quantity, TotalAmount = productItem.Price * order.Quantity, Date = order.Date }); productItem.UnitInStock = productItem.UnitInStock - order.Quantity; ctx.SaveChanges(); } else { return(BadRequest("InSufficent count")); } } else { return(BadRequest("The product is not available")); } } } catch (Exception ex) { return(BadRequest("Invalid data")); } return(Ok()); }
private void addAmount() { int CustomerID = Convert.ToInt16(Session["CustomerID"].ToString()); using (ecommerceEntities context = new ecommerceEntities()) { var cart = (from c in context.ProductOrderStatus join p in context.Products on c.ProductId equals p.ProductID where c.CustomerId == CustomerID && c.StatusId == 1 select new { p.ProductPrice, c.Quantity }); decimal?amt = 0; foreach (var i in cart) { amt += (i.ProductPrice * i.Quantity); } txtAmount.Text = amt.ToString(); } }
protected void btnSave_Click(object sender, EventArgs e) { using (ecommerceEntities context = new ecommerceEntities()) { //Getting user info based on session variable int id = (int)Session["CustomerID"]; Customer cust = context.Customers.Where(i => i.CustomerID == id).FirstOrDefault(); cust.CustomerName = txtName.Text; cust.sex = ddlGender.SelectedValue; cust.UserName = txtUserName.Text; cust.Address = txtAddress.Text; cust.email = txtEmail.Text; cust.ContactNumber = txtContact.Text; context.SaveChanges(); } lblError.Visible = true; lblError.Text = "Details successfully updated"; }
public IHttpActionResult GETProducts() { List <ProductDTO> products = null; using (var ctx = new ecommerceEntities()) { products = ctx.Products.Select(x => new ProductDTO() { ID = x.ID, Name = x.Name, Price = x.Price, Description = x.Description, UnitInStock = x.UnitInStock }).ToList(); } if (products == null) { return(NotFound()); } return(Ok(products)); }