public List <MOptions> GetOptionsByProfile(MOptions MOptions, Session eSession) { List <MOptions> options = new List <MOptions>(); OptionsRequest request = new OptionsRequest(); OptionsResponse response = new OptionsResponse(); request.Options = MOptions; request.Session = eSession; request.ApplicationToken = ConfigurationManager.AppSettings["ApplicationToken"].ToString(); string bodyrequest = JsonConvert.SerializeObject(request); string statuscode = string.Empty; string bodyresponse = new Helper().InvokeApi("security/api/Options", "GetOptionsByProfile", bodyrequest, ref statuscode); if (statuscode.Equals("OK")) { response = JsonConvert.DeserializeObject <OptionsResponse>(bodyresponse); if (response.Code.Equals("0")) { options = response.Options; } } return(options); }
public OptionsResponse GetOptionsByProfile([FromBody] OptionsRequest request) { OptionsResponse response = new OptionsResponse(); MOptions option = new MOptions(); List <MOptions> options = new List <MOptions>(); try { /*METODO QUE VALIDA EL TOKEN DE APLICACIÓN*/ if (!BAplication.ValidateAplicationToken(request.ApplicationToken)) { response.Code = "2"; response.Message = Messages.ApplicationTokenNoAutorize; return(response); } /*************FIN DEL METODO*************/ option.ProfileId = request.Options.ProfileId; int Val = 0; options = BOptions.Sel(option, ref Val); if (Val.Equals(0)) { response.Code = "0"; //0=> Ëxito | 1=> Validación de Sistema | 2 => Error de Excepción response.Message = Messages.Success; } else if (Val.Equals(2)) { response.Code = "2"; //0=> Ëxito | 1=> Validación de Sistema | 2 => Error de Excepción response.Message = String.Format(Messages.ErrorObtainingReults, "options"); } else { response.Code = "1"; //0=> Ëxito | 1=> Validación de Sistema | 2 => Error de Excepción response.Message = String.Format(Messages.NotReults, "options"); } } catch (Exception ex) { response.Code = "2"; //0=> Ëxito | 1=> Validación de Sistema | 2 => Error de Excepción response.Message = ex.Message; } response.Options = options.ToArray(); return(response); }
public static List <MOptions> Sel(MOptions ent, ref int Val) { List <MOptions> lisQuery = new List <MOptions>(); using (SqlConnection con = new SqlConnection(ConnectionDB.GetConnectionString())) { try { SqlCommand cmd = new SqlCommand("sp_ProfileOptions_Sel", con); cmd.Parameters.Add("@IProfileId", SqlDbType.VarChar).Value = ent.ProfileId; cmd.CommandTimeout = 0; cmd.CommandType = CommandType.StoredProcedure; con.Open(); Val = 1; using (var reader = cmd.ExecuteReader()) { while (reader.Read()) { MOptions entRow = new MOptions(); entRow.ProfileId = Convert.ToInt32(reader["ProfileId"]); entRow.OptionId = Convert.ToInt32(reader["OptionId"]); entRow.FlagActive = Convert.ToInt32(reader["FlagActive"]); entRow.Title = Convert.ToString(reader["Title"]); entRow.TitleSubModule = Convert.ToString(reader["TitleSubModule"]); entRow.TitleModule = Convert.ToString(reader["TitleModule"]); lisQuery.Add(entRow); Val = 0; } } con.Close(); } catch (Exception ex) { Val = 2; } } return(lisQuery); }
public ActionResult GetMenu(string id, PerfilViewModel model) { PanelViewModel modelObj = new PanelViewModel(); List <MOptions> lstResult = null; List <MOptions> lstQuery; string strController = string.Empty; MOptions entOpciones = new MOptions(); UserIdentity objUserIdenty = AutenticationManager.GetUser(); Session objSession = new Session() { UserId = AutenticationManager.GetUser().IdUsuario, }; entOpciones.ProfileId = Convert.ToInt32(id); lstResult = new WebApiOptions().GetOptions(entOpciones, objSession); AutenticationManager.SetOpciones(lstResult); AutenticationManager.SetPerfil(Convert.ToInt32(id)); modelObj.PerfilId = id; lstQuery = lstResult.Where(x => x.Action == 1).ToList(); modelObj.Items = new List <PanelTab>(); foreach (var item in lstQuery) { PanelTab pnlTab = new PanelTab(); pnlTab.Items = new List <PanelTabItem>(); pnlTab.Id = "p" + item.OptionId.ToString(); pnlTab.Text = item.Title; var lstN2 = lstResult.Where(a => a.Action == 2 && a.IdFather == item.OptionId); foreach (var itemN2 in lstN2) { PanelTabItem pnlTabItem = new PanelTabItem() { Id = itemN2.OptionId.ToString(), Text = itemN2.Title, IsSeparator = true }; pnlTab.Items.Add(pnlTabItem); var lstN3 = lstResult.Where(a => a.Action == 3 && a.IdFather == itemN2.OptionId); foreach (var itemN3 in lstN3) { pnlTab.Items.Add(new PanelTabItem() { Id = itemN3.OptionId.ToString(), Text = itemN3.Title, Action = string.IsNullOrEmpty(itemN3.Link) ? "" : itemN3.Link }); } } modelObj.Items.Add(pnlTab); } return(PartialView("_TabMenu", modelObj)); }