当前位置: 首页>>代码示例>>C#>>正文


C# BaseMessage.setError方法代码示例

本文整理汇总了C#中CmsWeb.MobileAPI.BaseMessage.setError方法的典型用法代码示例。如果您正苦于以下问题:C# BaseMessage.setError方法的具体用法?C# BaseMessage.setError怎么用?C# BaseMessage.setError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CmsWeb.MobileAPI.BaseMessage的用法示例。


在下文中一共展示了BaseMessage.setError方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateUser

        public ActionResult CreateUser(string data)
        {
            BaseMessage dataIn = BaseMessage.createFromString(data);
            MobilePostCreate mpc = JsonConvert.DeserializeObject<MobilePostCreate>(dataIn.data);

            MobileAccount account = MobileAccount.Create(mpc.first, mpc.last, mpc.email, mpc.phone, mpc.dob);

            var br = new BaseMessage();

            // todo: notify user based on ResultCode
            if (account.Result == MobileAccount.ResultCode.BadEmailAddress || account.Result == MobileAccount.ResultCode.FoundMultipleMatches)
            {
                br.setError(BaseMessage.API_ERROR_CREATE_FAILED);
            }
            else
            {
                br.setNoError();
                br.data = account.User.Username;
            }

            return br;
        }
开发者ID:clearfunction,项目名称:bvcms,代码行数:22,代码来源:MobileAPIController.cs

示例2: FetchPerson

        public ActionResult FetchPerson(string data)
        {
            // Authenticate first
            var result = AuthenticateUser();
            if (!result.IsValid) return AuthorizationError(result);

            BaseMessage dataIn = BaseMessage.createFromString(data);
            MobilePostFetchPerson mpfs = JsonConvert.DeserializeObject<MobilePostFetchPerson>(dataIn.data);

            BaseMessage br = new BaseMessage();

            var person = DbUtil.Db.People.SingleOrDefault(p => p.PeopleId == mpfs.id);

            if (person == null)
            {
                br.setError(BaseMessage.API_ERROR_PERSON_NOT_FOUND);
                br.data = "Person not found.";
                return br;
            }

            br.setNoError();
            br.count = 1;

            if (dataIn.device == BaseMessage.API_DEVICE_ANDROID)
            {
                br.data = SerializeJSON(new MobilePerson().populate(person), dataIn.version);
            }
            else
            {
                List<MobilePerson> mp = new List<MobilePerson>();
                mp.Add(new MobilePerson().populate(person));
                br.data = SerializeJSON(mp, dataIn.version);
            }

            return br;
        }
开发者ID:vanutama,项目名称:bvcms,代码行数:36,代码来源:MobileAPIController.cs

示例3: FetchPerson

        public ActionResult FetchPerson(string data)
        {
            // Authenticate first
            if (!Auth())
                return BaseMessage.createErrorReturn("Authentication failed, please try again", BaseMessage.API_ERROR_INVALID_CREDENTIALS);

            BaseMessage dataIn = BaseMessage.createFromString(data);

            BaseMessage br = new BaseMessage();

            var person = DbUtil.Db.People.SingleOrDefault(p => p.PeopleId == dataIn.argInt);

            if (person == null)
            {
                br.setError(BaseMessage.API_ERROR_PERSON_NOT_FOUND);
                br.data = "Person not found.";
                return br;
            }

            br.setNoError();
            br.count = 1;

            if (dataIn.device == BaseMessage.API_DEVICE_ANDROID)
            {
                br.data = SerializeJSON(new CheckInPerson().populate(person), dataIn.version);
            }
            else
            {
                List<CheckInPerson> mp = new List<CheckInPerson>();
                mp.Add(new CheckInPerson().populate(person));
                br.data = SerializeJSON(mp, dataIn.version);
            }

            return br;
        }
开发者ID:clearfunction,项目名称:bvcms,代码行数:35,代码来源:CheckInAPIController.cs


注:本文中的CmsWeb.MobileAPI.BaseMessage.setError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。