public async Task <IActionResult> BuyItemPrivate() { if (User.Identity.IsAuthenticated) { var allCharsResponse = HttpContext.GetAccountInfo(); if (allCharsResponse == null) { return(BadRequest()); } var playerName = Request.Form["BuyerName"].ToString(); if (allCharsResponse.AccountNames.Contains(playerName, StringComparer.OrdinalIgnoreCase)) { var objectId = int.Parse(Request.Form["ObjectId"]); var buyerId = int.Parse(Request.Form["SellerId"]); var count = int.Parse(Request.Form["Count"]); var sellerName = Request.Form["BuyerName"].ToString(); var response = await _requestService.BuyPrivateStoreItem(objectId, buyerId, count, sellerName); if (response.ResponseCode == 200) { return(Content("ok:" + response.ResponseMessage)); } return(Content(response.ResponseMessage)); } return(BadRequest()); } return(Unauthorized()); }
public async Task <IActionResult> BuyItemPrivate() { if (User.Identity.IsAuthenticated) { var allCharsResponse = HttpContext.GetAccountInfo(); if (allCharsResponse == null) { return(BadRequest()); } var playerName = Request.Form["BuyerName"].ToString(); if (allCharsResponse.AccountNames.Contains(playerName, StringComparer.OrdinalIgnoreCase)) { var objectId = int.Parse(Request.Form["ObjectId"]); var buyerId = int.Parse(Request.Form["SellerId"]); var count = int.Parse(Request.Form["Count"]); var sellerName = Request.Form["BuyerName"].ToString(); var response = await _requestService.BuyPrivateStoreItem(objectId, buyerId, count, sellerName); switch (response.ResponseCode) { case 200: return(Content("ok:" + response.ResponseMessage)); case 500: return(Content(_localizer["Something went wrong!"])); case 501: return(Content(_localizer["You can't do that while holding a cursed weapon."])); case 502: return(Content(_localizer["This player is not selling anything."])); case 503: return(Content(_localizer["You are not authorized to do that."])); case 504: return(Content(_localizer["You don't have the items required."])); } } return(BadRequest()); } return(Unauthorized()); }