public void Describe(DescribeContext context)
        {
            Func <IShapeFactory, dynamic> formFactory =
                shapeFactory =>
            {
                var priorities    = this.basicDataService.GetPriorities().ToList();
                var statusRecords = this.basicDataService.GetStatusRecords().ToList().Select(c => new BasicDataRecordViewModel {
                    Id = c.Id, Name = c.Name
                }).ToList();
                var serviceRecords = this.basicDataService.GetServices().Select(c => c.Record).ToList();
                var projects       = this.projectService.GetProjects(null).AsPart <ProjectPart>().ToList();

                Collection <SelectListItem> prioritySelectList = new Collection <SelectListItem>();
                Collection <SelectListItem> statusSelectList   = new Collection <SelectListItem>();
                Collection <SelectListItem> serviceSelectList  = new Collection <SelectListItem>();
                Collection <SelectListItem> projectList        = new Collection <SelectListItem>();

                Converter.Fill(prioritySelectList, null, priorities);
                prioritySelectList.Insert(0, new SelectListItem());

                Converter.Fill(statusSelectList, null, statusRecords);
                statusSelectList.Insert(0, new SelectListItem());

                Converter.Fill(serviceSelectList, null, serviceRecords);
                serviceSelectList.Insert(0, new SelectListItem());

                Converter.FillByIdentity(projectList, projects);

                Collection <SelectListItem> dueDates = CRMHelper.GetDueDateItems(this.T);

                ContentItemSetPermissionsViewModel permissionsViewModel = this.contentOwnershipHelper.CreateModel();
                permissionsViewModel.Users.Insert(0, new SelectListItem());
                var t = this.Shape.Form(_main: this.Shape.CreateTicketActivity(
                                            Priorities: prioritySelectList,
                                            Projects: projectList,
                                            StatusList: statusSelectList,
                                            Services: serviceSelectList,
                                            DueDates: dueDates,
                                            Organization: permissionsViewModel
                                            ));

                return(t);
            };

            context.Form(CreateTicketActivityForm.Name, formFactory);
        }
Beispiel #2
0
        public void Describe(DescribeContext context)
        {
            Func <IShapeFactory, dynamic> formFactory =
                shapeFactory =>
            {
                var priorities    = this.basicDataService.GetPriorities().ToList();
                var statusRecords = this.basicDataService.GetStatusRecords().ToList().Select(c => new BasicDataRecordViewModel {
                    Id = c.Id, Name = c.Name
                }).ToList();
                var serviceRecords = this.basicDataService.GetServices().ToList();

                Collection <SelectListItem> prioritySelectList = new Collection <SelectListItem>();
                Collection <SelectListItem> statusSelectList   = new Collection <SelectListItem>();
                Collection <SelectListItem> serviceSelectList  = new Collection <SelectListItem>();

                Converter.Fill(prioritySelectList, null, priorities);
                prioritySelectList.Insert(0, new SelectListItem());

                Converter.Fill(statusSelectList, null, statusRecords);
                statusSelectList.Insert(0, new SelectListItem());

                Converter.Fill(serviceSelectList, null, serviceRecords);
                serviceSelectList.Insert(0, new SelectListItem());

                Collection <SelectListItem> dueDates = CRMHelper.GetDueDateItems(this.T);

                var t = this.Shape.Form(
                    Id: "UpdateTicketForm",
                    _Parts: this.Shape.UpdateTicketActivity(
                        Priorities: prioritySelectList,
                        StatusList: statusSelectList,
                        Services: serviceSelectList,
                        DueDates: dueDates
                        ));

                return(t);
            };

            context.Form(UpdateTicketActivityForm.Name, formFactory);
        }
Beispiel #3
0
        protected override DriverResult Editor(TicketMenuItemPart part, dynamic shapeHelper)
        {
            var statusRecords = this.basicDataService.GetStatusRecords().ToList().Select(c => new BasicDataRecordViewModel {
                Id = c.Id, Name = c.Name
            }).ToList();
            Collection <SelectListItem> statusSelectList = new Collection <SelectListItem>();

            int?statusId = part.Record.Status != null ? (int?)part.Record.Status.Id : null;

            Converter.Fill(statusSelectList, statusId, statusRecords);
            statusSelectList.Insert(0, new SelectListItem());

            Collection <SelectListItem> dueDates = CRMHelper.GetDueDateItems(this.T);

            if (part.Record.DueDateDays.HasValue)
            {
                dueDates
                .Where(c => c.Value == part.Record.DueDateDays.Value.ToString(CultureInfo.InvariantCulture))
                .ToList()
                .ForEach(c => c.Selected = true);
            }

            ContentItemSetPermissionsViewModel permissionsViewModel = this.contentOwnershipHelper.CreateModel();

            permissionsViewModel.Users.Insert(0, new SelectListItem());
            if (part.Record.User != null)
            {
                permissionsViewModel
                .Users
                .Where(c => c.Value == part.Record.User.Id.ToString(CultureInfo.InvariantCulture))
                .ToList()
                .ForEach(c => c.Selected = true);
            }

            if (part.Record.BusinessUnit != null)
            {
                permissionsViewModel
                .BusinessUnits
                .Where(c => c.BusinessUnitId == part.Record.BusinessUnit.Id)
                .ToList()
                .ForEach(c => c.Checked = true);
            }

            if (part.Record.Team != null)
            {
                permissionsViewModel
                .Teams
                .Where(c => c.TeamId == part.Record.Team.Id)
                .ToList()
                .ForEach(c => c.Checked = true);
            }

            return(ContentShape("Parts_TicketMenuItem_Edit",
                                () =>
            {
                var model = new TicketMenuItemViewModel(
                    statusSelectList,
                    dueDates,
                    permissionsViewModel.Users,
                    permissionsViewModel.BusinessUnits,
                    permissionsViewModel.Teams);

                return shapeHelper.EditorTemplate(TemplateName: "Parts/TicketMenuItem", Model: model, Prefix: Prefix);
            }));
        }