Ejemplo n.º 1
0
 public ActionResult CommitActivity(Activity activity)
 {
     activityRepository.Commit(activity, CurrentUser);
     TempData["message"] = string.Format("Изменения в мероприятии \"{0}\" были сохранены", activity.ActivityName);
     if (HttpContext.User.IsInRole("Administrators"))
     {
         return(RedirectToAction("ActivitiesAdministration"));
     }
     else
     {
         return(RedirectToAction("CommitActivityList"));
     }
 }
Ejemplo n.º 2
0
        public IActionResult Edit(Activity activity)
        {
            if (!ModelState.IsValid)
            {
                ActivityEditViewModel activityEditViewModel = new ActivityEditViewModel();
                activityEditViewModel.Priorities = htmlHelper.GetEnumSelectList <Priority>();
                activityEditViewModel.Activity   = activity;
                return(View(activityEditViewModel));
            }

            if (activity.Id > 0)
            {
                activityRepository.Update(activity);
                TempData["Message"] = $"Zadanie '{activity.Title}' zostało zapisane.";
            }
            else
            {
                activityRepository.Add(activity);
                TempData["Message"] = $"Zadanie '{activity.Title}' zostało utworzone.";
            }

            activityRepository.Commit();
            return(RedirectToAction("Index"));
        }