Exemple #1
0
        public ActionResult CreateSection(ChangeSectionModel model)
        {
            if (ModelState.IsValid)
            {
                var result = repository.AddSection(new Section { SectionTitle = model.SectionTitle });

                if (!result) {
                    TempData["failure"] = "Раздел не был добавлен.";
                }
                else
                {
                    TempData["success"] = "Раздел был добавлен.";
                }
            }
            else
            {
                TempData["failure"] = "Раздел не был добавлен.";
            }
            ModelState.Clear();
            return RedirectToAction("GetSections");
        }
Exemple #2
0
        public ActionResult _SubmitSectionChange(ChangeSectionModel section)
        {
            using (var context = new SimpleMembershipContext())
            {
                var db_section = context.Sections.FirstOrDefault(x => x.SectionId == section.SectionId);

                if (ModelState.IsValid)
                {
                    try
                    {
                        db_section.SectionTitle = section.SectionTitle;
                        context.SaveChanges();
                    }
                    catch
                    {
                        Response.StatusCode = (int)HttpStatusCode.BadRequest;
                    }
                }
                else
                {
                    section.SectionTitle = db_section.SectionTitle;
                    Response.StatusCode = (int)HttpStatusCode.BadRequest;
                }
            }
            return PartialView("_Section", section);
        }
Exemple #3
0
 public ActionResult _HideRenameForm(ChangeSectionModel section)
 {
     return PartialView("_Section", section);
 }
Exemple #4
0
 public ActionResult _RenameSection(ChangeSectionModel section)
 {
     return PartialView(section);
 }
Exemple #5
0
        public ActionResult RemoveSection(ChangeSectionModel section)
        {
            if (ModelState.IsValid)
            {
                var result = repository.RemoveSection(section.SectionId);

                if (result)
                {
                    section = null;
                }
                else
                {
                    Response.StatusCode = (int)HttpStatusCode.BadRequest;
                }
            }
            else
            {
                Response.StatusCode = (int)HttpStatusCode.BadRequest;
            }
            return PartialView("_Section", section);
        }