Ejemplo n.º 1
0
        public ActionResult Complain(GeneralComplain complain, HttpPostedFileBase doc)
        {
            string path;

            if (doc != null)
            {
                var filename  = Path.GetFileName(doc.FileName);
                var extension = Path.GetExtension(filename).ToLower();
                if (extension == ".jpg" || extension == ".png" || extension == ".jpeg")
                {
                    path = HostingEnvironment.MapPath(Path.Combine("~/Content/Images/", filename));
                    doc.SaveAs(path);
                    complain.ImageUrl = "~/Content/Images/" + filename;
                }
                else
                {
                    ModelState.AddModelError("", "Document size must be less then 5MB");
                    return(View(complain));
                }
                if (ModelState.IsValid)
                {
                    db.GeneralComplains.Add(complain);
                    db.SaveChanges();

                    return(RedirectToAction("Index", "Store"));
                }
            }

            ModelState.AddModelError("", "Please upload image");
            return(View(complain));
        }
Ejemplo n.º 2
0
        public ActionResult DeleteConfirmed(int id)
        {
            GeneralComplain generalComplain = db.GeneralComplains.Find(id);

            db.GeneralComplains.Remove(generalComplain);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 3
0
        // GET: Admin/Complains/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            GeneralComplain generalComplain = db.GeneralComplains.Find(id);

            if (generalComplain == null)
            {
                return(HttpNotFound());
            }
            return(View(generalComplain));
        }