Ejemplo n.º 1
0
        public ActionResult Edit(SectionsViewModel sectionsViewModel, int id)
        {
            var section = _db.Sections.Find(id);
            section.SectionName = sectionsViewModel.SectionName;
            section.SectionStatus = sectionsViewModel.SectionStatus;
            section.SectionRemarks = sectionsViewModel.SectionRemarks;
            section.LawId = sectionsViewModel.SelectedLawId;
            section.SectionRefId = sectionsViewModel.SelectedSection;

            _db.Entry(section).State = EntityState.Modified;
            _db.SaveChanges();
            return RedirectToAction("Index");
        }
Ejemplo n.º 2
0
 public ActionResult Delete(int id)
 {
     var section = _db.Sections.Find(id);
     if (section == null)
     {
         return HttpNotFound();
     }
     var sectionsViewModel = new SectionsViewModel()
     {
         SectionName =  section.SectionName,
         SectionRemarks =  section.SectionRemarks,
         SectionStatus =  section.SectionStatus
     };
     return View(sectionsViewModel);
 }
Ejemplo n.º 3
0
 public ActionResult Edit(int id)
 {
     var section = _db.Sections.Find(id);
     if (section == null)
     {
         return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
     }
     var laws = _db.Laws.ToList();
     var sectionViewModel = new SectionsViewModel()
     {
         SectionName =  section.SectionName,
         SectionRemarks =  section.SectionRemarks,
         SectionStatus = section.SectionStatus,
         SelectedLawId = Convert.ToInt32(section.LawId),
         SelectedSection = Convert.ToInt32(section.SectionRefId) , //test it
         Sections = _db.Sections.Where(s => s.LawId == section.LawId).ToList(),
         Laws = laws
     };
     return View(sectionViewModel);
 }
Ejemplo n.º 4
0
 public ActionResult GetSections(LawsViewModel lawsViewModel)
 {
     var sections = _db.Sections.Where(s => s.LawId == lawsViewModel.SelectedLaw).ToList();
     string lawName =
         _db.Laws.Where(l => l.LawId == lawsViewModel.SelectedLaw).Select(l => l.LawTitle).SingleOrDefault();
     ViewBag.LawName = lawName;
     SectionsViewModel sectionsViewModel = new SectionsViewModel() { Sections = sections,SelectedLawId=lawsViewModel.SelectedLaw };
     return View(sectionsViewModel);
 }
Ejemplo n.º 5
0
 public ActionResult SectionForm(SectionsViewModel sectionViewModel,int selectedLawId,int? selectedSection)
 {
     var maxId = _db.Sections.Max(s => s.SectionId) + 1;
         var section = new Section()
         {
             SectionId = maxId,
             SectionName = sectionViewModel.SectionName,
             SectionCode = "S-" + maxId,
             LawId = selectedLawId,
             SectionRemarks = sectionViewModel.SectionRemarks,
             SectionStatus = sectionViewModel.SectionStatus,
             SectionDateTimeStamp = DateTime.Now,
             TerminalName = Environment.MachineName,
             UserId = User.Identity.GetUserId(),
             SectionRefId = Convert.ToInt32(selectedSection)
         };
         _db.Sections.Add(section);
         _db.SaveChanges();
         return RedirectToAction("Index");
 }