// GET: Activity/Edit/{id} public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } bool isSuperAdmin = User.IsInAnyRoles("SuperAdmin"); var organisationId = UserOrganisationId; var centres = NidanBusinessService.RetrieveCentres(organisationId, e => isSuperAdmin || e.CentreId == UserCentreId); var activityAssigneeGroups = NidanBusinessService.RetrieveActivityAssigneeGroups(organisationId, e => isSuperAdmin || e.CentreId == UserCentreId).Items.ToList(); var projects = NidanBusinessService.RetrieveProjects(organisationId, e => e.CentreId == UserCentreId).Items.ToList(); var activityTypes = NidanBusinessService.RetrieveActivityTypes(organisationId, e => true).Items.ToList(); var taskStates = NidanBusinessService.RetrieveTaskStates(organisationId, e => true).Items.ToList(); var activity = NidanBusinessService.RetrieveActivity(organisationId, id.Value, e => true); if (activity == null) { return(HttpNotFound()); } var viewModel = new ActivityViewModel { Centres = new SelectList(centres, "CentreId", "Name"), ActivityAssigneeGroups = new SelectList(activityAssigneeGroups, "ActivityAssigneeGroupId", "Name"), Projects = new SelectList(projects, "ProjectId", "Name"), TaskStates = new SelectList(taskStates, "TaskStateId", "Name"), ActivityTypes = new SelectList(activityTypes, "ActivityTypeId", "Name"), Activity = activity }; viewModel.HoursList = new SelectList(viewModel.HoursType, "Id", "Name"); viewModel.MinutesList = new SelectList(viewModel.MinutesType, "Id", "Name"); return(View(viewModel)); }
public ActionResult Create(ActivityViewModel activityViewModel) { bool isSuperAdmin = User.IsInAnyRoles("SuperAdmin"); var organisationId = UserOrganisationId; var personnelId = UserPersonnelId; var centreId = UserCentreId; if (ModelState.IsValid) { activityViewModel.Activity.OrganisationId = organisationId; activityViewModel.Activity = NidanBusinessService.CreateActivity(organisationId, personnelId, centreId, activityViewModel.Activity); return(RedirectToAction("Index")); } activityViewModel.Centres = new SelectList(NidanBusinessService.RetrieveCentres(organisationId, e => isSuperAdmin || e.CentreId == UserCentreId).ToList()); activityViewModel.ActivityAssigneeGroups = new SelectList(NidanBusinessService.RetrieveActivityAssigneeGroups(organisationId, e => isSuperAdmin || e.CentreId == UserCentreId).Items.ToList()); activityViewModel.Projects = new SelectList(NidanBusinessService.RetrieveProjects(organisationId, e => e.CentreId == UserCentreId).Items.ToList()); activityViewModel.ActivityTypes = new SelectList(NidanBusinessService.RetrieveActivityTypes(organisationId, e => true).Items.ToList()); return(View(activityViewModel)); }
// GET: Activity/Create //[Authorize(Roles = "Admin , SuperAdmin")] public ActionResult Create() { bool isSuperAdmin = User.IsInAnyRoles("SuperAdmin"); var organisationId = UserOrganisationId; var centres = NidanBusinessService.RetrieveCentres(organisationId, e => isSuperAdmin || e.CentreId == UserCentreId); var activityAssigneeGroups = NidanBusinessService.RetrieveActivityAssigneeGroups(organisationId, e => isSuperAdmin || e.CentreId == UserCentreId).Items.ToList(); var projects = NidanBusinessService.RetrieveProjects(organisationId, e => e.CentreId == UserCentreId).Items.ToList(); var activityTypes = NidanBusinessService.RetrieveActivityTypes(organisationId, e => true).Items.ToList(); var viewModel = new ActivityViewModel() { Centres = new SelectList(centres, "CentreId", "Name"), ActivityAssigneeGroups = new SelectList(activityAssigneeGroups, "ActivityAssigneeGroupId", "Name"), Projects = new SelectList(projects, "ProjectId", "Name"), ActivityTypes = new SelectList(activityTypes, "ActivityTypeId", "Name"), Activity = new Activity() }; viewModel.HoursList = new SelectList(viewModel.HoursType, "Id", "Name"); viewModel.MinutesList = new SelectList(viewModel.MinutesType, "Id", "Name"); return(View(viewModel)); }
public ActionResult List(Paging paging, List <OrderBy> orderBy) { bool isSuperAdmin = User.IsInAnyRoles("SuperAdmin"); return(this.JsonNet(NidanBusinessService.RetrieveActivityAssigneeGroups(UserOrganisationId, e => isSuperAdmin || e.CentreId == UserCentreId, orderBy, paging))); }