本文整理汇总了C#中CmsWeb.MobileAPI.BaseMessage类的典型用法代码示例。如果您正苦于以下问题:C# BaseMessage类的具体用法?C# BaseMessage怎么用?C# BaseMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BaseMessage类属于CmsWeb.MobileAPI命名空间,在下文中一共展示了BaseMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: fetchCountries
public ActionResult fetchCountries()
{
// Authenticate first
var authError = Authenticate();
if (authError != null) return authError;
var countries = (from e in DbUtil.Db.Countries
orderby e.Id
select e).ToList();
BaseMessage br = new BaseMessage();
List<MobileCountry> ma = new List<MobileCountry>();
br.error = 0;
br.type = BaseMessage.API_TYPE_SYSTEM_COUNTRIES;
br.count = countries.Count();
foreach (var country in countries)
{
ma.Add(new MobileCountry().populate(country));
}
br.data = JsonConvert.SerializeObject(ma);
return br;
}
示例2: fetchMaritalStatuses
public ActionResult fetchMaritalStatuses()
{
// Authenticate first
var authError = Authenticate();
if (authError != null) return authError;
var statuses = (from e in DbUtil.Db.MaritalStatuses
orderby e.Id
select e).ToList();
BaseMessage br = new BaseMessage();
List<MobileMaritalStatus> ma = new List<MobileMaritalStatus>();
br.error = 0;
br.type = BaseMessage.API_TYPE_SYSTEM_MARITAL_STATUSES;
br.count = statuses.Count();
foreach (var status in statuses)
{
ma.Add(new MobileMaritalStatus().populate(status));
}
br.data = JsonConvert.SerializeObject(ma);
return br;
}
示例3: createErrorReturn
public static BaseMessage createErrorReturn(string sErrorMessage)
{
BaseMessage br = new BaseMessage();
br.data = sErrorMessage;
return br;
}
示例4: HomeActions
public ActionResult HomeActions(string data)
{
var actions = from p in DbUtil.Db.MobileAppActions
join i in DbUtil.Db.MobileAppIcons on p.Id equals i.ActionID
join s in DbUtil.Db.MobileAppIconSets on i.SetID equals s.Id
where p.Enabled == true
where s.Active == true
orderby p.Order
select new MobileHomeAction
{
type = p.Type,
title = p.Title,
option = p.Option,
data = p.Data,
icon = i.Url,
loginType = p.LoginType,
roles = p.Roles
};
BaseMessage br = new BaseMessage();
br.error = 0;
br.count = actions.Count();
br.data = JsonConvert.SerializeObject(actions.ToList());
return br;
}
示例5: createTypeErrorReturn
public static BaseMessage createTypeErrorReturn()
{
BaseMessage br = new BaseMessage();
br.data = "ERROR: Type mis-match in API call.";
return br;
}
示例6: createErrorReturn
public static BaseMessage createErrorReturn(string sErrorMessage, int errorCode = 1)
{
BaseMessage br = new BaseMessage();
br.data = sErrorMessage;
br.error = errorCode;
return br;
}
示例7: Authenticate
public ActionResult Authenticate(string data)
{
if (!Auth())
return BaseMessage.createErrorReturn("Authentication failed, please try again", BaseMessage.API_ERROR_INVALID_CREDENTIALS);
var br = new BaseMessage();
br.error = 0;
br.data = JsonConvert.SerializeObject(new CheckInInformation(getSettings(), getCampuses(), getLabelFormats()));
return br;
}
示例8: Countries
public ActionResult Countries(string data)
{
var countries = getCountries();
BaseMessage br = new BaseMessage();
br.error = 0;
br.count = countries.Count();
br.data = JsonConvert.SerializeObject(countries.ToList());
return br;
}
示例9: CheckSessionToken
public ActionResult CheckSessionToken(string data)
{
var result = AuthenticateUser();
if (!result.IsValid)
return AuthorizationError(result);
var br = new BaseMessage();
br.setNoError();
return br;
}
示例10: AcceptTask
public ActionResult AcceptTask(string data)
{
var result = AuthenticateUser();
if (!result.IsValid) return AuthorizationError(result);
BaseMessage dataIn = BaseMessage.createFromString(data);
TaskModel.AcceptTask(dataIn.argInt);
BaseMessage br = new BaseMessage();
br.count = 1;
br.setNoError();
return br;
}
示例11: States
public ActionResult States(string data)
{
var states = from e in DbUtil.Db.StateLookups
orderby e.StateCode
select new MobileState
{
code = e.StateCode,
name = e.StateName
};
BaseMessage br = new BaseMessage();
br.error = 0;
br.count = states.Count();
br.data = JsonConvert.SerializeObject(states.ToList());
return br;
}
示例12: Countries
public ActionResult Countries(string data)
{
var countries = from e in DbUtil.Db.Countries
orderby e.Id
select new MobileCountry
{
id = e.Id,
code = e.Code,
description = e.Description
};
BaseMessage br = new BaseMessage();
br.error = 0;
br.count = countries.Count();
br.data = JsonConvert.SerializeObject(countries.ToList());
return br;
}
示例13: Authenticate
public ActionResult Authenticate(string data)
{
var dataIn = BaseMessage.createFromString(data);
var result = AuthenticateUser(requirePin: true);
if (!result.IsValid)
return AuthorizationError(result);
savePushID(Util.UserPeopleId ?? 0, dataIn.device, dataIn.key);
MobileSettings ms = getUserInfo();
var br = new BaseMessage();
br.setNoError();
br.data = SerializeJSON(ms, dataIn.version);
br.token = result.User.ApiSessions.Single().SessionToken.ToString();
return br;
}
示例14: GivingLink
public ActionResult GivingLink(string data)
{
var dataIn = BaseMessage.createFromString(data);
var givingOrgId = DbUtil.Db.Organizations
.Where(o => o.RegistrationTypeId == RegistrationTypeCode.OnlineGiving)
.Select(x => x.OrganizationId).FirstOrDefault();
var br = new BaseMessage();
if (dataIn.version >= BaseMessage.API_VERSION_3)
{
br.data = DbUtil.Db.ServerLink($"OnlineReg/{givingOrgId}?{dataIn.getSourceQueryString()}");
}
else
{
br.data = DbUtil.Db.ServerLink($"OnlineReg/{givingOrgId}");
}
br.setNoError();
return br;
}
示例15: FetchTasks
public ActionResult FetchTasks(string data)
{
var result = AuthenticateUser();
if (!result.IsValid) return AuthorizationError(result);
BaseMessage dataIn = BaseMessage.createFromString(data);
var tasks = from t in DbUtil.Db.ViewIncompleteTasks
orderby t.CreatedOn, t.StatusId, t.OwnerId, t.CoOwnerId
where t.OwnerId == Util.UserPeopleId || t.CoOwnerId == Util.UserPeopleId
select t;
var complete = (from c in DbUtil.Db.Tasks
where c.StatusId == TaskStatusCode.Complete
where c.OwnerId == Util.UserPeopleId || c.CoOwnerId == Util.UserPeopleId
orderby c.CreatedOn descending
select c).Take(20);
BaseMessage br = new BaseMessage();
switch (dataIn.device)
{
case BaseMessage.API_DEVICE_ANDROID:
{
Dictionary<int, MobileTask> taskList = new Dictionary<int, MobileTask>();
foreach (var item in tasks)
{
MobileTask task = new MobileTask().populate(item, Util.UserPeopleId ?? 0);
taskList.Add(task.id, task);
}
foreach (var item in complete)
{
MobileTask task = new MobileTask().populate(item, Util.UserPeopleId ?? 0);
taskList.Add(task.id, task);
}
br.data = SerializeJSON(taskList, dataIn.version);
break;
}
case BaseMessage.API_DEVICE_IOS:
{
List<MobileTask> taskList = new List<MobileTask>();
foreach (var item in tasks)
{
MobileTask task = new MobileTask().populate(item, Util.UserPeopleId ?? 0);
taskList.Add(task);
}
foreach (var item in complete)
{
MobileTask task = new MobileTask().populate(item, Util.UserPeopleId ?? 0);
taskList.Add(task);
}
br.data = SerializeJSON(taskList, dataIn.version);
break;
}
}
br.count = tasks.Count();
br.setNoError();
return br;
}