public IActionResult Vote(string app) { var usr = _authService.GetAuthUser(Request, Response); if (usr == null) { return(_authService.UnAuthenticatedResult); } var remoteIpAddress = Request.HttpContext.Connection.RemoteIpAddress.ToString(); var vote = _competitionService.VoteForApplication(usr, app, remoteIpAddress); var suc = new ActionResultViewModel(); if (vote) { suc.Title = "Success !"; suc.SubTitle = "Vote sent successfully!"; suc.TextClass = "text-success"; suc.ButtonClass = "btn-success"; suc.ActionButtonLink = "/MemeOff/Index"; suc.ActionButtonText = "Back to the contest"; } else { suc.Title = "Error !"; suc.SubTitle = "Voting failed please try again!"; suc.TextClass = "text-danger"; suc.ButtonClass = "btn-danger"; suc.ActionButtonLink = "/MemeOff/Application"; suc.ActionButtonText = "Back to contest"; } return(new RedirectToActionResult("Result", "Home", routeValues: suc)); }
public IActionResult Result(ActionResultViewModel model) { if (model == null) { return(new RedirectResult("/Home/Index")); } return(View(model)); }
public IActionResult DoAddWallet() { var usr = authService.GetAuthUser(Request, Response); if (usr == null) { return(authService.UnAuthenticatedResult); } var badRes = new ActionResultViewModel() { Title = "Failure!", SubTitle = "Wallet was not added!", ActionButtonLink = "/Home/AddWallet/", ActionButtonText = "Back", ButtonClass = "btn-danger", TextClass = "text-danger" }; if (!Request.Form.ContainsKey("privkey") || !Request.Form.ContainsKey("name")) { return(new RedirectToActionResult("Result", "Home", routeValues: badRes)); } var key = Request.Form["privkey"].ToString(); var name = Request.Form["name"].ToString(); var suc = authService.AddWallet(key, name, usr); if (suc) { var res = new ActionResultViewModel() { Title = "Success!", SubTitle = "Wallet added successfully!", ActionButtonLink = "/Home/Wallet/", ActionButtonText = "Go to wallet", ButtonClass = "btn-success", TextClass = "text-success" }; return(new RedirectToActionResult("Result", "Home", routeValues: res)); } else { return(new RedirectToActionResult("Result", "Home", routeValues: badRes)); } }
public IActionResult DoApplication(ApplicationViewModel model) { var usr = _authService.GetAuthUser(Request, Response); if (usr == null) { return(_authService.UnAuthenticatedResult); } var suc = new ActionResultViewModel { Title = "Error !", SubTitle = "Application was not sent successfully! Please check your image, also your title should be less then 30 characters.", TextClass = "text-danger", ButtonClass = "btn-danger", ActionButtonLink = "/MemeOff/Application", ActionButtonText = "Back to application" }; if (String.IsNullOrWhiteSpace(model.Title) || model.Image == null) { return(new RedirectToActionResult("Result", "Home", routeValues: suc)); } var ok = _competitionService.Apply(model, usr); if (ok) { suc.Title = "Success !"; suc.SubTitle = "Application sent successfully!"; suc.TextClass = "text-success"; suc.ButtonClass = "btn-success"; suc.ActionButtonLink = "/MemeOff/Index"; suc.ActionButtonText = "Back to the contest"; } return(new RedirectToActionResult("Result", "Home", routeValues: suc)); }
public IActionResult Send() { nodeCom.UpdatePeers(); var usr = authService.GetAuthUser(Request, Response); if (usr == null) { return(authService.UnAuthenticatedResult); } var from = ""; if (Request.Form.ContainsKey("wallet")) { if (Request.Form["wallet"].ToString().Split('-').Length > 1) { from = Request.Form["wallet"].ToString().Split('-')[1]; } else { return(authService.UnAuthenticatedResult); } } var wallet = context.Wallets.First(r => r.OwnerId == usr.UId && r.Address == from); if (wallet == null) { return(authService.UnAuthenticatedResult); } var oo = nodeCom.SendTransaction(usr, wallet, Request.Form); var suc = new ActionResultViewModel(); if (oo != null) { var ht = new HistoricalTransaction() { State = TransactionState.NonVerified, TimeOfCreation = DateTime.UtcNow, TransactionId = oo.Body.TransactionId, TransactionJson = JsonConvert.SerializeObject(oo), User = usr }; context.HistoricalTransactions.Add(ht); suc.Title = "Success !"; suc.SubTitle = "Transaction sent successfully!"; suc.TextClass = "text-success"; suc.ButtonClass = "btn-success"; suc.ActionButtonLink = "/Home/Wallet"; suc.ActionButtonText = "Back to wallet"; return(new RedirectToActionResult("Result", "Home", routeValues: suc)); } else { suc.Title = "Error !"; suc.SubTitle = "Transaction was not sent successfully!"; suc.TextClass = "text-danger"; suc.ButtonClass = "btn-danger"; suc.ActionButtonLink = "/Home/Wallet"; suc.ActionButtonText = "Back to wallet"; return(new RedirectToActionResult("Result", "Home", routeValues: suc)); } }