Exemplo n.º 1
0
        public IActionResult AddActivity(String activityName, short?parentActivityName = null)
        {
            var result = _activityData.Add(new Activity {
                Name = activityName, ParentActivityId = parentActivityName
            });

            if (!result)
            {
                return(RedirectToAction("Error", "Home", new ErrorViewModel
                {
                    Error = "مشکل در ایجاد فعالیت جدید!"
                }));
            }
            return(RedirectToAction("AdminPanel"));
        }
Exemplo n.º 2
0
        public IActionResult Create(ActivityEditModel model)
        {
            if (ModelState.IsValid)
            {
                var newActivity = new Activity();
                newActivity.Name     = model.Name;
                newActivity.Category = model.Category;

                _activityData.Add(newActivity);

                return(RedirectToAction(nameof(Details), new { id = newActivity.Id }));
            }
            else
            {
                return(View());
            }
        }
        public IActionResult AddPost(ActivityAdd model)
        {
            Activity activity = new Activity();

            activity.StudentID      = model.StudentID;
            activity.ProfessorID    = model.ProfessorID;
            activity.ActivityTypeID = model.ActivityTypeID;
            activity.CourseID       = model.CourseID;
            activity.Points         = model.Points;

            activity.Date         = model.Date;
            activity.ActivityType = _activityTypeData.Find(model.CourseID, model.ActivityTypeID);
            List <Activity> activities = _activityData.FindSpecific(model.StudentID, model.CourseID, model.ActivityTypeID).ToList();

            foreach (Activity activity1 in activities)
            {
                activity1.Valid = false;
                _activityData.Delete(activity1);
            }
            if (activity.ActivityType.Required == true)
            {
                Console.WriteLine("obavezna je true");
                if (model.Points >= activity.ActivityType.MaxPoints * 0.5)
                {
                    Console.WriteLine("br poena true");
                    activity.Status = true;
                }
                else
                {
                    Console.WriteLine("br poena false");
                    activity.Status = false;
                }
            }
            else
            {
                activity.Status = true;
            }
            activity.Valid = true;
            _activityData.Add(activity);
            _courseStudentData.CalculateGrade(model.StudentID, model.CourseID, _activityData.FindAllByStudentCourse(model.StudentID, model.CourseID));
            return(RedirectToAction("Courses", "Course"));
        }
Exemplo n.º 4
0
        public IActionResult OnPost()
        {
            if (!ModelState.IsValid) // check the ModelState (also for checking attempted inputs etc.)
            {
                return(Page());
            }

            if (Activity.Id > 0)
            {
                _activityData.Update(Activity);
            }
            else
            {
                _activityData.Add(Activity);
            }

            _activityData.Commit();
            TempData["Message"] = "Activity saved.";
            return(RedirectToPage("./Detail", new { activityId = Activity.Id }));
        }