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 })); }
//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)); }
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)); }
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)); }