예제 #1
0
        public ActionResult Pop(int idItem, int idProfile)
        {
            IEnumerable <tblPerfilItens> profileItemList;
            IEnumerable <tblPerfilItens> profilesAdded;

            profileItemList = _profileItemTraining.GetProfileItems();
            //Retorna todos os itens que fazem referencia ao Perfil chamado 'idProfile'
            profilesAdded = _perfilTrainingItemXPerfilItem.SetUpPerfilItensLista(idProfile);

            ProfileItemListModel profileItem = new ProfileItemListModel();

            profileItem.idProfile        = idProfile;
            profileItem.ProfileItem      = profileItemList;
            profileItem.ProfileItemAdded = profilesAdded;
            profileItem.ProfileName      = _profileTraining.GetTrainingProfileById(idProfile).Nome;
            UpdateModel(profileItem);

            try
            {
                _perfilTrainingItemXPerfilItem.DeletePerfilTrainingItemXPerfilItem(idProfile, idItem);
            }
            catch
            {
                return(RedirectToAction("Details", new { idProfile = idProfile }));
            }

            return(RedirectToAction("Details", new { idProfile = idProfile }));
        }
예제 #2
0
        //GET: Activity/Details/5
        //[AccessHelper(Menu = MenuHelper.Associacao, Screen = ScreensHelper.PerfilTreinamentoItemXPerfilItem, Feature = FeaturesHelper.Editar)]
        public ActionResult Details(int idProfile)
        {
            // Declaração de variaveis
            tblPerfilTreinamentoxPerfilItem profileXprofileItem = new tblPerfilTreinamentoxPerfilItem();

            profileXprofileItem.IdPerfilTreinamento = idProfile;
            profileXprofileItem.tblPerfis           = _profileTraining.GetTrainingProfileById(idProfile);


            IEnumerable <tblPerfilItens> profileItemList;
            IEnumerable <tblPerfilItens> profilesAdded;

            profileItemList = _profileItemTraining.GetProfileItemsNotAssociated(idProfile);
            //Retorna todos os itens que fazem referencia ao Perfil chamado 'idProfile'
            profilesAdded = _perfilTrainingItemXPerfilItem.SetUpPerfilItensLista(idProfile);

            ProfileItemListModel profileItem = new ProfileItemListModel();

            profileItem.idProfile        = idProfile;
            profileItem.ProfileItem      = profileItemList;
            profileItem.ProfileItemAdded = profilesAdded;
            profileItem.ProfileName      = _profileTraining.GetTrainingProfileById(idProfile).Nome;
            UpdateModel(profileItem);



            return(View("Edit", profileXprofileItem));
        }
예제 #3
0
        public ActionResult Push(int idItem, int idProfile, int ordem = 0)
        {
            tblPerfilTreinamentoxPerfilItem profileXprofileItem = new tblPerfilTreinamentoxPerfilItem();

            profileXprofileItem.IdPerfilTreinamento = idProfile;
            profileXprofileItem.IdPerfilItem        = idItem;
            profileXprofileItem.Ordem = ordem;

            ViewBag.ProfileName = _profileTraining.GetTrainingProfileById(idProfile).Nome;


            var exits       = _perfilTrainingItemXPerfilItem.checkIfPerfilTrainingItemXPerfilItemAlreadyExits(profileXprofileItem);
            var ordemExists = _perfilTrainingItemXPerfilItem.checkIfOrderAlreadyExits(profileXprofileItem);

            if (ModelState.IsValid && ordem != 0 && ordem.ToString().Length <= 4)
            {
                if (!exits && !ordemExists)
                {
                    _perfilTrainingItemXPerfilItem.CreatePerfilTrainingItemXPerfilItem(profileXprofileItem);

                    return(RedirectToAction("Details", new { idProfile = idProfile }));
                }
            }

            IEnumerable <tblPerfilItens> profileItemList;
            IEnumerable <tblPerfilItens> profilesAdded;

            profileItemList = _profileItemTraining.GetProfileItems();
            //Retorna todos os itens que fazem referencia ao Perfil chamado 'idProfile'
            profilesAdded = _perfilTrainingItemXPerfilItem.SetUpPerfilItensLista(idProfile);

            ProfileItemListModel profileItem = new ProfileItemListModel();

            profileItem.idProfile        = idProfile;
            profileItem.ProfileItem      = profileItemList;
            profileItem.ProfileItemAdded = profilesAdded;
            profileItem.ProfileName      = _profileTraining.GetTrainingProfileById(idProfile).Nome;
            //UpdateModel(profileItem);

            /*GERANDO MENSAGENS DE VALIDAÇÃO*/
            if (exits)
            {
                ModelState.AddModelError("IdPerfilTreinamento", "Perfil já associado a esse item");
            }
            if (ordemExists)
            {
                ModelState.AddModelError("Ordem", "Ordem já existente");
            }
            if (ordem == 0)
            {
                ModelState.AddModelError("Ordem", "Ordem deve ser preenchida(apenas números)");
            }
            if (ordem.ToString().Length > 4)
            {
                ModelState.AddModelError("Ordem", "Ordem deve ter no máximo 4 digitos");
            }

            return(View("Edit", profileXprofileItem));
        }
예제 #4
0
        public ActionResult SearchProfileItem(int idProfile, string nome = "")
        {
            ViewBag.Name = nome;

            IEnumerable <tblPerfilItens> profileItemFiltered;
            IEnumerable <tblPerfilItens> profilesAdded;

            profileItemFiltered = _profileItemTraining.GetProfileItemByName(nome, idProfile);
            profilesAdded       = _perfilTrainingItemXPerfilItem.SetUpPerfilItensLista(idProfile);

            ProfileItemListModel profileItem = new ProfileItemListModel();

            profileItem.idProfile        = idProfile;
            profileItem.ProfileItem      = profileItemFiltered;
            profileItem.ProfileItemAdded = profilesAdded;
            profileItem.ProfileName      = _profileTraining.GetTrainingProfileById(idProfile).Nome;
            UpdateModel(profileItem);

            return(PartialView("_Lista", profileItem));
        }