public IHttpActionResult PutProdectT(int id, ProdectT prodectT) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != prodectT.ProdectID) { return(BadRequest()); } db.Entry(prodectT).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ProdectTExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult SendEmail(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } OrderT orderT = db.OrderTs.Find(id); if (orderT == null) { return(HttpNotFound()); } var Prodectid = db.OrderTs.Find(id).ProdectID; ProdectT Prodect = db.ProdectTs.Find(Prodectid); var UserTid = db.OrderTs.Find(id).UserID; UserT UserT = db.UserTs.Find(UserTid); var FullName = UserT.FullName; var ProdectName = Prodect.ProdectName; var Price = Prodect.Price; var Phone = UserT.Phone; var Address = UserT.Address; var Country = UserT.Country; var City = UserT.City; var Email = UserT.Email; ViewBag.msg = "Hi Plese diver the Prodect :- " + ProdectName + " To the Cotomar :- " + FullName + " ,the Prodect Price is :- " + Price + " ,the Cotomar Phone :- " + Phone + " ,the Cotomar Email is:- " + Email + " and the Cotomar Address is:- " + Address + " , " + Country + " , " + City; return(View(orderT)); }
public ActionResult DeleteConfirmed(int id) { ProdectT prodectT = db.ProdectTs.Find(id); db.ProdectTs.Remove(prodectT); db.SaveChanges(); return(RedirectToAction("Index")); }
public IHttpActionResult GetProdectT(int id) { ProdectT prodectT = db.ProdectTs.Find(id); if (prodectT == null) { return(NotFound()); } return(Ok(prodectT)); }
public ActionResult Edit([Bind(Include = "ProdectID,ProdectName,ProdectNameAR,Descriotion,DescriotionAR,Price,Rating,ImagePath,CategorieID")] ProdectT prodectT) { if (ModelState.IsValid) { db.Entry(prodectT).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CategorieID = new SelectList(db.CategoriesTs, "CategorieID", "CategorieName", prodectT.CategorieID); return(View(prodectT)); }
public IHttpActionResult PostProdectT(ProdectT prodectT) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.ProdectTs.Add(prodectT); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = prodectT.ProdectID }, prodectT)); }
public IHttpActionResult DeleteProdectT(int id) { ProdectT prodectT = db.ProdectTs.Find(id); if (prodectT == null) { return(NotFound()); } db.ProdectTs.Remove(prodectT); db.SaveChanges(); return(Ok(prodectT)); }
// GET: ProdectsMcv/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ProdectT prodectT = db.ProdectTs.Find(id); if (prodectT == null) { return(HttpNotFound()); } return(View(prodectT)); }
public ActionResult Create([Bind(Include = "ProdectID,ProdectName,ProdectNameAR,Descriotion,DescriotionAR,Price,Rating,ImagePath,CategorieID")] ProdectT prodectT) { //string FileName = Path.GetFileNameWithoutExtension(prodectT.) if (ModelState.IsValid) { db.ProdectTs.Add(prodectT); db.SaveChanges(); return(RedirectToAction("Indexx")); } ViewBag.CategorieID = new SelectList(db.CategoriesTs, "CategorieID", "CategorieName", prodectT.CategorieID); return(View(prodectT)); }
//[HttpPost,ActionName("Upload")] //public ActionResult UploadFiles(HttpPostedFileBase file ,ProdectT prodect ) //{ // if (ModelState.IsValid) // { // try // { // if (file != null) // { // string fileName = Path.GetFileNameWithoutExtension(file.FileName); // string extension = Path.GetExtension(file.FileName); // fileName = fileName + DateTime.Now.ToString("yymmssfff") + extension; // prodect.ImagePath = "~/UploadedFiles/" + fileName; // fileName = "C:\"Users\"Ans\"source\"repos\"MarketApp2\"AdminPanal" + "~/UploadedFiles/" + fileName; // file.SaveAs(fileName) // //string path = "C:\"Users\"Ans\"source\"repos\"MarketApp2\"AdminPanal\"UploadedFiles" + Path.GetFileName(file.FileName); // //string path = Path.Combine(Server.MapPath("~/UploadedFiles"), Path.GetFileName(file.FileName)); // /*file.SaveAs(path)*/; // db.ProdectTs.Add(prodect); // db.SaveChanges(); // } // ViewBag.FileStatus = "File uploaded successfully."; // } // catch (Exception) // { // ViewBag.FileStatus = "Error while file uploading."; // } // } // ModelState.Clear(); // return View(); //} // GET: ProdectsMcv/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ProdectT prodectT = db.ProdectTs.Find(id); if (prodectT == null) { return(HttpNotFound()); } ViewBag.CategorieID = new SelectList(db.CategoriesTs, "CategorieID", "CategorieName", prodectT.CategorieID); return(View(prodectT)); }
public ActionResult DeleteConfirmed(int id, string msg) { OrderT orderT = db.OrderTs.Find(id); ProdectT prodect = db.ProdectTs.Find(orderT.ProdectID); UserT user = db.UserTs.Find(orderT.UserID); CategoriesT categories = db.CategoriesTs.Find(prodect.CategorieID); oldOrder old = new oldOrder(); old.OrderNumber = orderT.OrderID; old.UserID = user.UserID; old.FullName = user.FullName; old.UserName = user.UserName; old.Password = user.Password; old.Email = user.Email; old.Phone = user.Phone; old.Address = user.Address; old.City = user.City; old.State = user.State; old.Country = user.Country; old.CategorieID = categories.CategorieName; old.ProdectID = prodect.ProdectID; old.ProdectName = prodect.ProdectName; old.ProdectNameAR = prodect.ProdectNameAR; old.Descriotion = prodect.Descriotion; old.DescriotionAR = prodect.DescriotionAR; old.Price = prodect.Price; old.Rating = prodect.Rating; old.CancelMassage = msg; db.oldOrders.Add(old); db.OrderTs.Remove(orderT); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult SendEmail(string receiver, string subject, string message, string orderId) { try { if (ModelState.IsValid) { var senderEmail = new MailAddress("*****@*****.**", "AnsBedoor"); var receiverEmail = new MailAddress(receiver, "Receiver"); var password = "******"; var sub = subject; var body = message; SmtpClient Client = new SmtpClient("smtp.gmail.com", 587); Client.EnableSsl = true; Client.Timeout = 100000; Client.DeliveryMethod = SmtpDeliveryMethod.Network; Client.UseDefaultCredentials = false; Client.Credentials = new NetworkCredential(senderEmail.Address, password); MailMessage mailMessage = new MailMessage(senderEmail.Address, receiverEmail.Address, subject, message); mailMessage.IsBodyHtml = true; mailMessage.BodyEncoding = UTF8Encoding.UTF8; using (var mess = new MailMessage(senderEmail, receiverEmail) { Subject = subject, Body = body }) { Client.Send(mailMessage); } var i = Convert.ToInt32(orderId); OrderT orderT = db.OrderTs.Find(i); ProdectT prodect = db.ProdectTs.Find(orderT.ProdectID); UserT user = db.UserTs.Find(orderT.UserID); CategoriesT categories = db.CategoriesTs.Find(prodect.CategorieID); oldOrder old = new oldOrder(); old.OrderNumber = orderT.OrderID; old.UserID = user.UserID; old.FullName = user.FullName; old.UserName = user.UserName; old.Password = user.Password; old.Email = user.Email; old.Phone = user.Phone; old.Address = user.Address; old.City = user.City; old.State = user.State; old.Country = user.Country; old.CategorieID = categories.CategorieName; old.ProdectID = prodect.ProdectID; old.ProdectName = prodect.ProdectName; old.ProdectNameAR = prodect.ProdectNameAR; old.Descriotion = prodect.Descriotion; old.DescriotionAR = prodect.DescriotionAR; old.Price = prodect.Price; old.Rating = prodect.Rating; db.oldOrders.Add(old); db.OrderTs.Remove(orderT); db.SaveChanges(); return(RedirectToAction("Index", "OrdersMcv", null)); } } catch (Exception ex) { ViewBag.Error = "Some Error"; } return(View()); }