// // GET : /account/maininfo/{accountName} // GET: /account/maininfo/name={accountName} // GET: /account/maininfo/id={accountId} public ActionResult MainInfo(string accountName, Guid? accountId) { Answer output; try { if (accountId == null && accountName == null) { output = new Answer(new Error("Account missing")); Response.StatusCode = 400; // Bad Request } else { var realId = accountId ?? Storage.Account.GetId(accountName); // get the informations of the given account var accountInfo = Storage.Account.GetInfo(realId); var accountToReturn = new Account(realId, accountInfo.Name, accountInfo.Description); output = new Answer(accountToReturn); } } catch (Exception exception) { // Result is an non-empty error XML element output = new Answer(HandleError(exception)); } return Serialize(output); }
// // GET : /list/owner/{idOfList} public ActionResult Owner(Guid? idOfList) { Answer output; try { if (idOfList == null) { output = new Answer(new Error("List id missing")); Response.StatusCode = 400; // Bad Request } else { // get accounts following a given list var ownerId = Storage.List.GetOwner(idOfList.GetValueOrDefault()); var ownerInfo = Storage.Account.GetInfo(ownerId); var ownerToReturn = new Account(ownerId, ownerInfo.Name, ownerInfo.Description); output = new Answer(ownerToReturn); } } catch (Exception exception) { output = new Answer(HandleError(exception)); } return Serialize(output); }