Ejemplo n.º 1
0
        public bool InsertOrUpdateRole(RoleModels model, ref string msg)
        {
            try
            {
                RoleApiModels paraBody = new RoleApiModels();
                paraBody.AppKey        = Commons.AppKey;
                paraBody.AppSecret     = Commons.AppSecret;
                paraBody.CreatedUser   = Commons.CreateUser;
                paraBody.RegisterToken = new RegisterTokenModels();

                paraBody.Name           = model.Name;
                paraBody.IsActive       = model.IsActive;
                paraBody.ListRoleModule = model.ListRoleModule;
                paraBody.ListRoleDrawer = model.ListRoleDrawer;

                paraBody.Id      = model.ID;
                paraBody.StoreId = model.StoreId;


                //====================
                var result = (ResponseApiModels)ApiResponse.Post <ResponseApiModels>(Commons.CreateOrEditRole, null, paraBody);
                if (result != null)
                {
                    if (result.Success)
                    {
                        return(true);
                    }
                    else
                    {
                        _logger.Error(result.Message);
                        msg = result.Message;
                        return(false);
                    }
                }
                else
                {
                    _logger.Error(result);
                    return(false);
                }
            }
            catch (Exception e)
            {
                _logger.Error("Role_InsertOrUpdate: " + e);
                return(false);
            }
        }
Ejemplo n.º 2
0
        public bool DeleteRole(string ID, ref string msg)
        {
            try
            {
                RoleApiModels paraBody = new RoleApiModels();
                paraBody.AppKey        = Commons.AppKey;
                paraBody.AppSecret     = Commons.AppSecret;
                paraBody.CreatedUser   = Commons.CreateUser;
                paraBody.RegisterToken = new RegisterTokenModels();
                paraBody.Id            = ID;

                //====================
                var result = (ResponseApiModels)ApiResponse.Post <ResponseApiModels>(Commons.DeleteRole, null, paraBody);
                if (result != null)
                {
                    if (result.Success)
                    {
                        return(true);
                    }
                    else
                    {
                        msg = result.Message;
                        _logger.Error(result.Message);
                        return(false);
                    }
                }
                else
                {
                    _logger.Error(result);
                    return(false);
                }
            }
            catch (Exception e)
            {
                msg = e.ToString();
                _logger.Error("Role_Delete: " + e);
                return(false);
            }
        }