public ActionResult JwtBearer()
 {
     try
     {
         string bearerToken = _bearerService.GenerateJwt(LoggedInUserId.ToString());
         return(Ok(bearerToken));
     }
     catch
     {
         return(View());
     }
 }
Ejemplo n.º 2
0
        public JsonResult SaveSecurityLevel(Dictionary <string, string> allCheck, Dictionary <string, string> allDropDown, Dictionary <string, string> allMode, List <string> allModuleId, string RoleId) //, List<string> allModule List<string> allSecurityId
        {
            try
            {
                var Result    = 0;
                var trx       = allCheck;
                var trxId     = 1;
                var ModuleIds = allModuleId.Where(w => int.TryParse(w, out trxId));

                foreach (var id in ModuleIds)
                {
                    var    txtId         = "txtId" + id;
                    var    txtSecurityId = "txtSecurityId" + id;
                    var    txtMode       = "txtMode" + id;
                    int    ChkId         = 0;
                    int    ddlId         = 0; //ddlId=allDropDownid == securityid
                    string mode          = string.Empty;

                    if (allCheck.ContainsKey(txtId))
                    {
                        int.TryParse(allCheck[txtId], out ChkId);
                    }

                    if (allDropDown.ContainsKey(txtSecurityId))
                    {
                        int.TryParse(allDropDown[txtSecurityId], out ddlId);
                    }

                    if (allMode.ContainsKey(txtMode))
                    {
                        mode = allMode[txtMode];
                    }

                    if (mode == "S" && ChkId == 1)
                    {
                        var param = new { RoleId = RoleId, ModuleId = Convert.ToInt32(id) };

                        var ExRole = menuSPService.SP_GETAspNetRoleModuleIdIsactiveZero(param);


                        if (ExRole.Tables[0].Rows.Count == 1)
                        {
                            int NetRoleModuleId = Convert.ToInt32(ExRole.Tables[0].Rows[0][0]);
                            var param6          = new { AspNetRoleModuleId = NetRoleModuleId, SecurityLevelId = ddlId };
                            menuSPService.SP_UPDATEAspNetRoleModuleIsActive(param6);
                        }
                        else
                        { //save
                            var param1 = new { RoleId = RoleId, ModuleId = Convert.ToInt32(id), SecurityLevelId = ddlId, IsActive = true, CreatedBy = LoggedInUserId.ToString(), CreateDate = DateTime.Now };

                            int Status = menuSPService.SaveAspNetRoleModule(param1);

                            Result = Status;
                        }
                    }
                    else if (mode == "U")
                    {
                        if (ChkId == 1)
                        {//row update
                            var param2 = new { RoleId = RoleId, ModuleId = Convert.ToInt32(id) };

                            var ExRole = menuSPService.SP_GETAspNetRoleModuleId(param2);

                            int AspNetRoleModuleId = Convert.ToInt32(ExRole.Tables[0].Rows[0][0]);

                            if (ExRole.Tables[0].Rows.Count == 1)
                            {
                                var param3 = new { AspNetRoleModuleId = AspNetRoleModuleId, SecurityLevelId = ddlId };
                                menuSPService.SP_UPDATEAspNetRoleSecurityLevelId(param3);
                            }
                            Result = 1;
                        }
                        else
                        {
                            var param4             = new { RoleId = RoleId, ModuleId = Convert.ToInt32(id) };
                            var ExRole             = menuSPService.SP_GETAspNetRoleModuleId(param4);
                            int AspNetRoleModuleId = Convert.ToInt32(ExRole.Tables[0].Rows[0][0]);

                            var param3 = new { AspNetRoleModuleId = AspNetRoleModuleId };
                            menuSPService.SP_UPDATEAspNetRoleModule(param3);
                            Result = 1;
                        }
                    }
                }
                return(Json(new { Result, JsonRequestBehavior.AllowGet }));
            }
            catch (Exception ex)
            {
                return(Json(new { Result = "ERROR" }));
            }
        }