protected async System.Threading.Tasks.Task Form0Submit(InnovationWebApp.Models.InnovateDb.Idea args) { try { if (isEdit) { var innovateDbUpdateIdeaResult = await InnovateDb.UpdateIdea(idea.id, idea); NotificationService.Notify(NotificationSeverity.Success, $"Success", $"Idea updated!"); } } catch (System.Exception innovateDbUpdateIdeaException) { NotificationService.Notify(NotificationSeverity.Error, $"Error", $"Unable to update Idea"); } try { if (!this.isEdit) { var innovateDbCreateIdeaResult = await InnovateDb.CreateIdea(args); idea = new InnovationWebApp.Models.InnovateDb.Idea(); NotificationService.Notify(NotificationSeverity.Success, $"Success", $"Idea created!"); } } catch (System.Exception innovateDbCreateIdeaException) { NotificationService.Notify(NotificationSeverity.Error, $"Error", $"Unable to create new Idea!"); } }
protected async System.Threading.Tasks.Task Button1Click(MouseEventArgs args) { try { int selectedId = idea.id; var innovateDbGetVoteResult = await InnovateDb.GetVotes(new Query() { Filter = "i => i.email.Equals(@0) && i.id.Equals(@1)", FilterParameters = new object[] { "*****@*****.**", idea.id } }); if (!innovateDbGetVoteResult.Any()) { Vote vote = new Vote(); vote.email = "*****@*****.**"; vote.id = idea.id; var innovateDbCreateVoteResult = await InnovateDb.CreateVote(vote); idea.votes += 1; await InnovateDb.UpdateIdea(idea.id, idea); NotificationService.Notify(NotificationSeverity.Success, $"Success", $"Your vote has been recorded"); } else { NotificationService.Notify(NotificationSeverity.Error, $"Error", $"You have already voted for this idea!"); } } catch (System.Exception innovateDbCreateIdeaException) { NotificationService.Notify(NotificationSeverity.Error, $"Error", $"Unable to add your vote!"); } }