public IActionResult Update(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            WhyUs whyUs = _db.WhyUs.FirstOrDefault(p => p.Id == id);

            if (whyUs == null)
            {
                return(NotFound());
            }
            return(View(whyUs));
        }
        public async Task <IActionResult> Update(int?id, WhyUs whyus)
        {
            if (id == null)
            {
                return(NotFound());
            }
            WhyUs dbWhyus = await _db.WhyUs.FindAsync(id);

            if (dbWhyus == null)
            {
                return(NotFound());
            }
            dbWhyus.Answer   = whyus.Answer;
            dbWhyus.Question = whyus.Question;
            await _db.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
Esempio n. 3
0
        public ActionResult AddWhyUs(WhyUs WhyUs, HttpPostedFileBase ImageFile)
        {
            if (ImageFile != null)
            {
                string fn            = Path.GetFileName(ImageFile.FileName);
                string fileExtension = fn.Remove(0, fn.IndexOf('.') + 1);
                fn = Common.SafeSubstring(WhyUs.Title, 0, 5) + "." + Common.RandomString(5) + "." + fileExtension;
                string SaveLocation = "~/Images/WhyUs/";
                WhyUs.ImagePath = Path.Combine(SaveLocation, fn);
                string FilePath = Server.MapPath(SaveLocation);
                ImageFile.SaveAs(Path.Combine(FilePath, fn));
            }

            if (WhyUsRepo.Insert(WhyUs))
            {
                Notify("Success", "Successfully added", "Product Added Successfully", false, false, true);
            }
            else
            {
                Notify("Error", "Technical Error", "Unable to add product due to technical issues", false, false, true);
            }

            return(RedirectToAction("Index", "WhyUs"));
        }
        public IActionResult Index()
        {
            WhyUs whyUs = _db.WhyUs.FirstOrDefault();

            return(View(whyUs));
        }
Esempio n. 5
0
 public bool Update(WhyUs WhyUs)
 {
     db.values.Add("@ID", WhyUs.ID.ToString());
     return(DBHelper.Update(WhyUs, "Where ID = @ID", db.values));
 }
Esempio n. 6
0
 public bool Insert(WhyUs WhyUs)
 {
     return(DBHelper.Insert(WhyUs));
 }