示例#1
0
        public async Task <IActionResult> Update(WhyChooseUs whyChooseUs)
        {
            if (User.Identity.IsAuthenticated && User.IsInRole("admin"))
            {
                if (whyChooseUs == null || !ModelState.IsValid)
                {
                    return(NotFound());
                }
                if (whyChooseUs.Heading == string.Empty)
                {
                    ModelState.AddModelError("", "Başlıq boş olmamalıdır");
                    return(View(whyChooseUs));
                }
                if (whyChooseUs.Content == string.Empty)
                {
                    ModelState.AddModelError("", "Məzmun boş olmamalıdır");
                    return(View(whyChooseUs));
                }
                if (whyChooseUs.Icon == string.Empty)
                {
                    ModelState.AddModelError("", "Ikon boş olmamalıdır");
                    return(View(whyChooseUs));
                }
                WhyChooseUs fromDb = await _context.whyChooseUs.FindAsync(whyChooseUs.Id);

                fromDb.Heading = whyChooseUs.Heading;
                fromDb.Content = whyChooseUs.Content;
                fromDb.Icon    = whyChooseUs.Icon;
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(Redirect("/admin/account"));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            WhyChooseUs whyChooseUs = db.WhyChooseUs.Find(id);

            db.WhyChooseUs.Remove(whyChooseUs);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "ID,Title,PrimaryTitle,Subtitle,Description")] WhyChooseUs whyChooseUs)
 {
     if (ModelState.IsValid)
     {
         db.Entry(whyChooseUs).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(whyChooseUs));
 }
        public ActionResult Create([Bind(Include = "ID,Title,PrimaryTitle,Subtitle,Description")] WhyChooseUs whyChooseUs)
        {
            if (ModelState.IsValid)
            {
                db.WhyChooseUs.Add(whyChooseUs);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(whyChooseUs));
        }
示例#5
0
        public async Task <IActionResult> Create([Bind(include: "IconClass, Title, Title_Az, Title_Ru, Description, Description_Az,Description_Ru")] WhyChooseUs chooseUs)
        {
            if (!ModelState.IsValid)
            {
                return(View(chooseUs));
            }

            _context.WhyChooseUs.Add(chooseUs);
            await _context.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
        // GET: WhyChooseUs/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            WhyChooseUs whyChooseUs = db.WhyChooseUs.Find(id);

            if (whyChooseUs == null)
            {
                return(HttpNotFound());
            }
            return(View(whyChooseUs));
        }
示例#7
0
        public async Task <IActionResult> Edit([Bind(include: "IconClass, Title, Title_Az, Title_Ru, Description, Description_Az,Description_Ru")] WhyChooseUs chooseUs, int id)
        {
            if (!ModelState.IsValid)
            {
                return(View(chooseUs));
            }
            var testimonialBefore = await _context.WhyChooseUs.FindAsync(id);

            testimonialBefore.IconClass      = chooseUs.IconClass;
            testimonialBefore.Title          = chooseUs.Title;
            testimonialBefore.Title_Az       = chooseUs.Title_Az;
            testimonialBefore.Title_Ru       = chooseUs.Title_Ru;
            testimonialBefore.Description    = chooseUs.Description;
            testimonialBefore.Description_Az = chooseUs.Description_Az;
            testimonialBefore.Description_Ru = chooseUs.Description_Ru;

            await _context.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
示例#8
0
        public IActionResult Create()
        {
            WhyChooseUs chooseUs = new WhyChooseUs();

            return(View(chooseUs));
        }