本文整理汇总了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;
}
示例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;
}
示例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;
}