コード例 #1
0
        public ActionResult DeleteConfirmed(int id, SectionScheduleType viewModel)
        {
            Section section    = db.Sections.Find(id);
            int     scheduleId = (int)section.ScheduleId;

            try
            {
                db.Sections.Remove(section);
                db.SaveChanges();
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(" HERE HRE HEKH ERKH ERKHER : " + e.Message);
                return(RedirectToAction("CannotDelete", viewModel));
            }

            if (viewModel.scheduleType == 1)
            {
                return(new RedirectToRouteResult(new RouteValueDictionary
                {
                    { "action", "IndexByClassroom/" + scheduleId },
                    { "controller", "Schedule" }
                }));
            }
            else if (viewModel.scheduleType == 2)
            {
                return(new RedirectToRouteResult(new RouteValueDictionary
                {
                    { "action", "IndexByProfessor/" + scheduleId },
                    { "controller", "Schedule" }
                }));
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }
コード例 #2
0
        /// <summary>
        /// Returns view to delete a section
        /// </summary>
        /// <param name="id"></param>
        /// <param name="scheduleType"></param>
        /// <returns></returns>
        public ActionResult Delete(int?id, int scheduleType)
        {
            //was an id passed in?
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            //grab section to delete
            Section section = db.Sections.Find(id);

            //does section exist?
            if (section == null)
            {
                return(HttpNotFound());
            }

            SectionScheduleType viewModel = new SectionScheduleType();

            viewModel.section      = section;
            viewModel.scheduleType = scheduleType;

            return(View(viewModel));
        }
コード例 #3
0
 /// <summary>
 /// returns view when section cannot be deleted
 /// </summary>
 /// <returns></returns>
 public ActionResult CannotDelete(SectionScheduleType viewModel)
 {
     return(View(viewModel));
 }