Beispiel #1
0
        public ActionResult Delete(ViewModels.Timetable model, int id)
        {
            Domain.Timetable timetable = timetableRepository.GetById(id);

            try
            {
                timeTableService.DeleteTimetable(timetable, id);
            }
            catch (ArgumentException)
            {
                ModelState.AddModelError("Error", "Cant' delete is already used");

                var timetableView = new ViewModels.Timetable()
                {
                    StartTime = timetable.StartTime,
                    //CategoryName = timetableDel.Category.Name,
                    StudioName = timetable.Studio.Name,
                    ClassName  = timetable.ClassType.Name,
                    UserName   = timetable.User.FirstName + " " + timetable.User.LastName,
                    Date       = timetable.Date
                };

                return(View(timetableView));
            }


            return(RedirectToAction("Index"));
        }