protected async override void OnInitialized() { CurrID = Guid.Empty; if (LocalData.componentBridge != null) { LocalData.componentBridge.OnRefresh = CmdRefresh; LocalData.componentBridge.OnConfirm = CmdActualDelete; } if (LocalData.IsAuthenticated) { await CmdGetAllCategories(); } else { LocalFunctions.CmdNavigate(); LocalFunctions.AddMessage("Please login", true, false); } base.OnInitialized(); }
public void CmdUpdate() { if (LocalData.TSCategoriesList.Any()) { if (!CurrID.Equals(Guid.Empty)) { if (!LocalData.TSCategoriesList.Single(x => x.ID == CurrID).Name.Equals("default")) { LocalData.AddOrUpdateMode = false; LocalData.currCategory = LocalData.TSCategoriesList.Single(x => x.ID == CurrID); LocalData.currCategoryName = LocalData.currCategory.Name; LocalData.compAddOrUpdateCategory.Bootstrap(); LocalFunctions.DisplayModal(ModalForm.AddOrUpdateCategory); } else { LocalFunctions.AddMessage("Default category can't be updated!", true, false); } } else { LocalFunctions.AddMessage("Category is not selected!", true, false); } } else { LocalFunctions.AddMessage("Category is not selected!", true, false); } }
public void CmdDelete() { if (LocalData.TSCategoriesList.Any()) { if (!CurrID.Equals(Guid.Empty)) { if (!LocalData.TSCategoriesList.Single(x => x.ID == CurrID).Name.Equals("default")) { if (LocalData.TSCategoriesList.Single(x => x.ID == CurrID).TodosCount == 0) { LocalFunctions.DisplayConfirm("CategoriesPage", "Are you sure to delete category?"); } else { LocalFunctions.AddMessage("Category has todos!", true, false); } } else { LocalFunctions.AddMessage("Default category can't be deleted!", true, false); } } else { LocalFunctions.AddMessage("Category is not selected!", true, false); } } else { LocalFunctions.AddMessage("Category is not selected!", true, false); } }
public void CmdUpdate() { if (LocalData.TsTodosList.Any()) { if (!CurrID.Equals(Guid.Empty)) { LocalData.AddOrUpdateMode = false; LocalData.CurrTodo = LocalData.TsTodosList.Single(x => x.ID == CurrID); if (!LocalData.CurrTodo.HasDueDate) { LocalData.CurrTodo.DueDate = LocalFunctions.ToLocalDate(DateTime.Now).AddDays(7); } if (!LocalData.CurrTodo.HasRemindDate) { LocalData.CurrTodo.RemindDate = LocalFunctions.ToLocalDate(DateTime.Now); } LocalData.BeforeUpdateTodo = GlobalFunctions.CopyObject <TSTodo>(LocalData.CurrTodo); LocalData.compAddOrUpdateTodo.Bootstrap(); LocalFunctions.DisplayModal(ModalForm.AddOrUpdateTodo); } else { LocalFunctions.AddMessage("Todo is not selected!", true, false); } } else { LocalFunctions.AddMessage("Todo is not selected!", true, false); } }
public async Task CmdAddOrUpdateTodo() { IsButtonDisabled = true; StateHasChanged(); if (LocalData.CurrTodo.HasDueDate) { if (LocalData.CurrTodo.DueDate <= LocalFunctions.ToLocalDate(DateTime.Now).AddMinutes(3)) { LocalFunctions.AddError("Due date should be minimum after 3 minute from now", MethodBase.GetCurrentMethod(), false, false); } } LocalFunctions.Validate(LocalData.CurrTodo); if (LocalFunctions.HasError()) { LocalFunctions.DisplayErrors(); } else { string a = string.Empty; if (LocalData.AddOrUpdateMode) { LocalData.CurrTodo.UserID = LocalData.CurrTSUser.ID; a = await WebApiFunctions.CmdAddTodo(LocalData.CurrTodo); } else { if (!GlobalFunctions.AreEqualTwoObjects(LocalData.CurrTodo, LocalData.BeforeUpdateTodo)) { a = await WebApiFunctions.CmdUpdateTodo(LocalData.CurrTodo); } else { LocalFunctions.AddMessage("Todo properties not updated", true, false); return; } } if (a.Equals("OK")) { LocalData.TsTodosList = new List <TSTodoEx>(); LocalData.btModal.Close(); LocalData.EventConsumerName = "TodosPage"; LocalData.componentBridge.InvokeRefresh(); } else { LocalFunctions.AddError(a, MethodBase.GetCurrentMethod(), true, false); } } IsButtonDisabled = false; }
public void CmdDisplayLogin() { if (!LocalData.IsAuthenticated) { LocalFunctions.DisplayModal(ModalForm.Login); } else { LocalFunctions.AddMessage("You are authenticated already", true, false); } }
public void CmdDisplayChangePassword() { if (LocalData.IsAuthenticated) { LocalFunctions.DisplayModal(ModalForm.ChangePassword); } else { LocalFunctions.AddMessage("You are not authenticated!", true, false); } }
protected override void OnInitialized() { if (!LocalData.IsAuthenticated) { LocalFunctions.CmdNavigate(); LocalFunctions.AddMessage("Please login", true, false); } base.OnInitialized(); }
public void CmdDisplayRegistration() { if (!LocalData.IsAuthenticated) { LocalFunctions.DisplayModal(ModalForm.Registration); } else { LocalFunctions.AddMessage("Please logout first, to register new user", true, false); } }
public async Task CmdAddOrUpdateCategory() { IsButtonDisabled = true; StateHasChanged(); if (LocalFunctions.Validate(LocalData.currCategory)) { if (!LocalData.currCategoryName.Equals(LocalData.currCategory.Name, StringComparison.InvariantCultureIgnoreCase)) { string a = string.Empty; if (LocalData.AddOrUpdateMode) { LocalData.currCategory.UserID = LocalData.CurrTSUser.ID; a = await WebApiFunctions.CmdAddCategory(LocalData.currCategory); } else { a = await WebApiFunctions.CmdUpdateCategory(LocalData.currCategory); } if (a.Equals("OK")) { LocalData.TSCategoriesList = new List <TSCategoryEx>(); LocalData.TSCategoriesDictionary = new Dictionary <Guid, string>(); LocalData.TsTodosList = new List <TSTodoEx>(); LocalData.btModal.Close(); //LocalFunctions.CmdNavigate("CategoriesPage"); LocalData.EventConsumerName = "CategoriesPage"; LocalData.componentBridge.InvokeRefresh(); } else { LocalFunctions.AddError(a, MethodBase.GetCurrentMethod(), true, false); } } else { LocalFunctions.AddMessage("Category name not updated", true, false); } } IsButtonDisabled = false; }
protected void CmdRegister() { LocalData.btModal.Close(); if (!LocalData.IsAuthenticated) { LocalFunctions.DisplayModal(ModalForm.Registration); } else { LocalFunctions.AddMessage("Please logout first, to register new user", true, false); } }
public void CmdLoginDemoUser() { if (LocalData.IsReady) { if (!LocalData.IsAuthenticated) { LocalFunctions.Authorize("DemoUser", "123456789"); } else { LocalFunctions.AddMessage("Please logout first, to log into demo user", true, false); } } else { LocalFunctions.AddMessage("Not ready yet, please try again", true, false); } }
public void CmdDelete() { if (LocalData.TsTodosList.Any()) { if (!CurrID.Equals(Guid.Empty)) { LocalFunctions.DisplayConfirm("TodosPage", "Are you sure to delete todo?"); } else { LocalFunctions.AddMessage("Todo is not selected!", true, false); } } else { LocalFunctions.AddMessage("Todo is not selected!", true, false); } }
public async Task CmdAddOrUpdateFeedback() { IsButtonDisabled = true; StateHasChanged(); if (LocalFunctions.Validate(LocalData.currFeedback)) { if (LocalData.oldFeedbackText != LocalData.currFeedback.Text.ToLower()) { await WebApiFunctions.CmdAddOrUpdateFeedback(LocalData.currFeedback); if (!LocalData.currFeedback.UserID.Equals(Guid.Empty)) { LocalData.btModal.Close(); //LocalFunctions.CmdNavigate("FeedbackPage"); LocalData.EventConsumerName = "FeedbackPage"; LocalData.componentBridge.InvokeRefresh(); LocalFunctions.AddMessage("Thank you for your feedback", true, false); } else { LocalFunctions.AddError("Error adding or updating feedback", MethodBase.GetCurrentMethod(), true, false); } } else { LocalFunctions.AddMessage("Feedback text not updated", true, false); } } IsButtonDisabled = false; }
private async void CmdLikeorDislike(bool b) { if (LocalData.IsAuthenticated) { if (!LocalData.CurrTSUser.UserName.Equals("demouser")) { if (LocalData.currReaction.UserID.Equals(Guid.Empty)) { await WebApiFunctions.CmdAddOrUpdateReaction(new TSReaction() { LikeOrDislike = b, ID = LocalData.currReaction.ID, UserID = LocalData.currReaction.UserID }); await LocalFunctions.GetStat(); LocalFunctions.AddMessage("Thank you for your feedback", true, false); } else { if (LocalData.currReaction.LikeOrDislike != b) { await WebApiFunctions.CmdAddOrUpdateReaction(new TSReaction() { LikeOrDislike = b, ID = LocalData.currReaction.ID, UserID = LocalData.currReaction.UserID }); await LocalFunctions.GetStat(); LocalFunctions.AddMessage("Thank you for your feedback", true, false); } else { if (LocalData.currReaction.LikeOrDislike) { LocalFunctions.AddMessage("You liked already", true, false); } else { LocalFunctions.AddMessage("You disliked already", true, false); } } } } else { LocalFunctions.AddMessage("Demo user can't vote", true, false); } } else { LocalFunctions.AddMessage("Only autenticated user can vote", true, false); } StateHasChanged(); }