Exemple #1
0
        // GET: ActivityTask/Edit/{id}
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            bool isSuperAdmin   = User.IsInAnyRoles("SuperAdmin");
            var  organisationId = UserOrganisationId;
            var  centreId       = UserCentreId;
            var  centres        = isSuperAdmin || centreId == 7 ? NidanBusinessService.RetrieveCentres(organisationId, e => true) : NidanBusinessService.RetrieveCentres(organisationId, e => e.CentreId == centreId);
            var  activityTask   = NidanBusinessService.RetrieveActivityTask(organisationId, id.Value, e => true);

            if (activityTask == null)
            {
                return(HttpNotFound());
            }
            var activityTaskDataGrid = NidanBusinessService.RetrieveActivityTaskDataGrids(organisationId, e => e.ActivityTaskId == activityTask.ActivityTaskId).Items.FirstOrDefault();
            var activityData         = NidanBusinessService.RetrieveActivity(organisationId, activityTask.ActivityId, e => true);
            var assignTos            = NidanBusinessService.RetrieveActivityAssignPersonnels(organisationId, activityTask.CentreId, activityData.ActivityAssigneeGroupId).Items.Select(e => e.Personnel).ToList();
            var monitoredByIds       = NidanBusinessService.RetrievePersonnels(organisationId, e => true).Items.ToList();
            var startDate            = activityData.StartDate;
            var endDate       = activityData.EndDate;
            var numberOfDays  = (endDate - startDate).TotalDays;
            var startTime     = activityData.StartHour + ":" + activityData.StartMinute + " " + activityData.StartTimeSpan;
            var endTime       = activityData.EndHour + ":" + activityData.EndMinute + " " + activityData.EndTimeSpan;
            var numberOfHours = DateTime.Parse(endTime).Subtract(DateTime.Parse(startTime));
            var monitoredBy   = NidanBusinessService.RetrievePersonnel(organisationId, activityData.CreatedBy);
            var viewModel     = new ActivityTaskViewModel
            {
                NumberOfDays       = numberOfDays,
                NumberOfHours      = numberOfHours,
                Centres            = new SelectList(centres, "CentreId", "Name"),
                AssignToList       = new SelectList(assignTos, "PersonnelId", "FullName"),
                MonitoredByList    = new SelectList(monitoredByIds, "PersonnelId", "FullName"),
                ActivityTask       = activityTask,
                Activity           = activityData,
                MonitoredById      = monitoredBy.PersonnelId,
                MonitoredByName    = monitoredBy.Fullname,
                ActivityTaskStatus = activityTaskDataGrid?.ActivityTaskStatus
            };

            viewModel.HoursList        = new SelectList(viewModel.HoursType, "Id", "Name");
            viewModel.MinutesList      = new SelectList(viewModel.MinutesType, "Id", "Name");
            viewModel.TaskPriorityList = new SelectList(viewModel.TaskPriority, "Value", "Name");
            return(View(viewModel));
        }
Exemple #2
0
        public ActionResult Create(ActivityTaskViewModel activityTaskViewModel)
        {
            bool isSuperAdmin   = User.IsInAnyRoles("SuperAdmin");
            var  organisationId = UserOrganisationId;
            var  personnelId    = UserPersonnelId;
            var  centreId       = UserCentreId;

            if (ModelState.IsValid)
            {
                activityTaskViewModel.ActivityTask.OrganisationId = organisationId;
                activityTaskViewModel.ActivityTask.ActivityId     = activityTaskViewModel.ActivityTask.Activity.ActivityId;
                activityTaskViewModel.ActivityTask = NidanBusinessService.CreateActivityTask(organisationId, personnelId, centreId, activityTaskViewModel.ActivityTask);
                return(RedirectToAction("Create", "ActivityTask", new { id = activityTaskViewModel.ActivityTask.ActivityId }));
            }
            var centres = isSuperAdmin || centreId == 7 ? NidanBusinessService.RetrieveCentres(organisationId, e => true) : NidanBusinessService.RetrieveCentres(organisationId, e => e.CentreId == centreId);

            activityTaskViewModel.Centres      = new SelectList(centres);
            activityTaskViewModel.AssignToList = new SelectList(NidanBusinessService.RetrieveActivityAssignPersonnels(organisationId, centreId, activityTaskViewModel.ActivityTask.Activity.ActivityAssigneeGroupId).Items.Select(e => e.Personnel).ToList());
            return(View(activityTaskViewModel));
        }
        public ActionResult ActivityAssignPersonnel(int centreId, int activityAssigneeGroupId)
        {
            var data = NidanBusinessService.RetrieveActivityAssignPersonnels(UserOrganisationId, centreId, activityAssigneeGroupId);

            return(this.JsonNet(data));
        }
Exemple #4
0
        public ActionResult GetPersonnel(int centreId, int activityAssigneeGroupId, Paging paging, List <OrderBy> orderBy)
        {
            var assignTos = NidanBusinessService.RetrieveActivityAssignPersonnels(UserOrganisationId, centreId, activityAssigneeGroupId).Items.ToList();

            return(this.JsonNet(assignTos));
        }