Ejemplo n.º 1
0
        public ActionResult updateRoleApplication(int[] chk_approle, string ddl_role)
        {
            RequestAdminRoleApplication     item;
            RequestAdminRoleApplicationList req      = new RequestAdminRoleApplicationList();
            ResponseAdminRoleApplication    response = new ResponseAdminRoleApplication();
            LogicAdminRoleApplication       log      = new LogicAdminRoleApplication();

            req.lst = new List <RequestAdminRoleApplication>();


            int opc = 0;

            for (int i = 0; i < chk_approle.Length; i++)
            {
                item = new RequestAdminRoleApplication();
                item.dateRegister  = System.DateTime.Now;
                item.userRegister  = Session["user"].ToString();
                item.dateUpdate    = System.DateTime.Now;
                item.userUpdate    = Session["user"].ToString();
                item.stateRecord   = true;
                item.idRole        = int.Parse(ddl_role);
                item.idApplication = chk_approle[i];
                item.flag          = 'N';
                req.lst.Add(item);
            }

            response = log.setApplication(req);

            return(RedirectToAction("RoleApplication"));
        }
        public ResponseAdminRoleApplication adminRoleApplication(RequestAdminRoleApplicationList request)
        {
            ResponseAdminRoleApplication response = new ResponseAdminRoleApplication();

            try
            {
                LogicAdminRoleApplication logicRoleApp = new LogicAdminRoleApplication();
                response = logicRoleApp.adminRoleApplication(request);
            }
            catch (System.Data.SqlClient.SqlException exSql)
            {
                // Cuando sea una excepción por SQL ya vendrá el mensaje de error controlado
                response.code    = exSql.ErrorCode;
                response.message = exSql.Message;
                response.status  = exSql.State;
            }
            catch (Exception ex)
            {
                // Registrar el error real
                LogicLogError logicError = new LogicLogError();
                LogError      error      = new LogError();

                error.module       = "ADMIN";
                error.method       = "adminRoleApplication";
                error.errorMessage = ex.Message;
                error.moreInfo     = "";

                logicError.newError(error);

                response.code    = -1;
                response.message = "Error no controlado, favor consultar con el administrador del sistema.";
            }

            return(response);
        }
        public ResponseAdminRoleApplication setApplication(RequestAdminRoleApplicationList req)
        {
            ResponseAdminRoleApplication response = new ResponseAdminRoleApplication();

            try
            {
                LogicCommon com  = new LogicCommon();
                string      json = com.HttpPost("RoleApplication/adminRoleApplication", req);
                response = JsonConvert.DeserializeObject <ResponseAdminRoleApplication>(json);

                return(response);
            }
            catch (Exception ex)
            {
                response.code    = -1;
                response.message = ex.Message;
            }

            return(response);
        }
Ejemplo n.º 4
0
        public ResponseAdminRoleApplication adminRoleApplication(RequestAdminRoleApplicationList request)
        {
            try
            {
                DataTable dt        = new DataTable();
                DataTable dtRoleApp = LogicPrincipal.makeDt("id,idRole,idApplication,stateRecord,userRegister,dateRegister,userUpdate,dateUpdate,flag");
                DataAdminRoleApplication        datRoleApplication = new DataAdminRoleApplication();
                RequestAdminRoleApplicationData requesData         = new RequestAdminRoleApplicationData();
                ResponseAdminRoleApplication    response           = new ResponseAdminRoleApplication();

                // Transformar la lista a un DataTable
                foreach (RequestAdminRoleApplication i in request.lst)
                {
                    DataRow r = dtRoleApp.NewRow();

                    r["id"]            = i.id.ToString();
                    r["idRole"]        = i.idRole.ToString();
                    r["idApplication"] = i.idApplication.ToString();
                    r["stateRecord"]   = i.stateRecord.ToString();
                    r["userRegister"]  = i.userRegister.ToString();
                    r["dateRegister"]  = i.dateRegister.ToString();
                    r["userUpdate"]    = i.userUpdate.ToString();
                    r["dateUpdate"]    = i.dateUpdate.ToString();
                    r["flag"]          = "N";

                    dtRoleApp.Rows.Add(r);
                }

                requesData.dtRoleApplication = dtRoleApp;

                dt = datRoleApplication.adminRoleApplication(requesData);

                if (dt != null)
                {
                    if (dt.Rows.Count > 0)
                    {
                        response.code    = int.Parse(dt.Rows[0]["code"].ToString());
                        response.message = dt.Rows[0]["message"].ToString();
                        response.status  = int.Parse(dt.Rows[0]["state"].ToString());
                    }
                }

                return(response);
            }
            catch (System.Data.SqlClient.SqlException exSql)
            {
                // Cuando sea una excepción por SQL ya vendrá el mensaje de error controlado
                throw exSql;
            }
            catch (Exception ex)
            {
                // Registrar el error real
                DataLogError datError = new DataLogError();
                LogError     error    = new LogError();

                error.module       = "ADMIN";
                error.method       = "adminRoleApplication";
                error.errorMessage = ex.Message;
                error.moreInfo     = "";

                datError.newError(error);

                // Modificar la excepción
                Exception exResult = new Exception("Error no controlado, favor consultar con el administrador del sistema.");
                throw exResult;
            }
        }