Example #1
0
        public void Create()
        {
            if (!CheckSessionAccess())
            {
                return;
            }

            if (!(Module.ManageCategory || Module.Administration))
            {
                View.SendAction(ModuleTicket.ActionType.NoPermission, this.CurrentCommunityId, ModuleTicket.InteractionType.None);
                View.ShowNoPermission();
                return;
            }

            Int64 newCatId = service.CategoryCreateSimple(View.Name, View.Description, View.Type);


            if (newCatId > 0)
            {
                IList <Domain.DTO.DTO_CategoryRole> Roles = new List <Domain.DTO.DTO_CategoryRole>();

                Int32 USerId = View.SelectedManagerID;

                //View.Roles;  //new List<Domain.DTO.DTO_CategoryRole>();
                if (USerId <= 0)
                {
                    Domain.DTO.DTO_CategoryRole ManRole = new Domain.DTO.DTO_CategoryRole();
                    ManRole.IsManager = true;
                    ManRole.PersonId  = UserContext.CurrentUserID;
                    Roles.Add(ManRole);
                }
                else
                {
                    Domain.DTO.DTO_CategoryRole ManRole = new Domain.DTO.DTO_CategoryRole();
                    ManRole.IsManager = true;
                    ManRole.PersonId  = USerId;
                    Roles.Add(ManRole);
                }

                Domain.DTO.DTO_AddRolesResponse roleResponse = service.CategoryRolesAdd(newCatId, Roles);

                //Begin Action
                List <KeyValuePair <int, String> > Objects = new List <KeyValuePair <int, string> >();
                Objects.Add(ModuleTicket.KVPgetPerson(this.UserContext.CurrentUserID));
                Objects.Add(ModuleTicket.KVPgetCategory(newCatId));

                View.SendAction(ModuleTicket.ActionType.CategoryCreate, this.CurrentCommunityId, ModuleTicket.InteractionType.UserWithLearningObject, Objects);
                //End Action

                //Gestire eventuali errori nell'aggiunta, tramite roleResponse...

                //View.CurrentCategoryId = newCatId;
                View.NavigateToEdit(newCatId);
                //InitView();
            }
            else
            {
                //Manage Error
            }
        }