public void Update(SMTPSettingItemViewModel item) { var x = repo.FindById(item.SMTPSettingId); x.SMTPUsername = item.SMTPUsername; x.SMTPPassword = item.SMTPPassword; x.SMTPServer = item.SMTPServer; x.SMTPPort = item.SMTPPort; x.EnableSSL = item.EnableSSL; x.IsActive = item.IsActive; repo.Update(x); }
protected void Save(SMTPSettingItemViewModel item) { try { if (item.SMTPSettingId > 0) { Service.Update(item); var index = Model.FindIndex(x => x.SMTPSettingId == this.currentItem.SMTPSettingId); Model[index] = item; } else { if (Model.Count() > 0) { item.SMTPSettingId = Model.Select(r => r.SMTPSettingId).Max() + 1; } else { item.SMTPSettingId = 1; } var newItem = Service.Create(item); if (newItem != null) { Model.Add(newItem); } } StateHasChanged(); } catch (Exception e) { Logger.LogError(e, $"{GetUserName()}*Error: SMTPSettingPage/Save"); ErrorModel.IsOpen = true; ErrorModel.ErrorContext = e.StackTrace; ErrorModel.ErrorMessage = e.Message; IsFailed = true; StateHasChanged(); } }
protected async Task Remove(SMTPSettingItemViewModel item) { var result = await MatDialogService.AskAsync($"Möchten Sie den Datensatz wirklich löschen?", new string[] { "Löschen", "Abbrechen" }); if (result == "Löschen") { try { Service.Delete(item); Model.Remove(item); } catch (Exception e) { Logger.LogError(e, $"{GetUserName()}*Error: SMTPSettingPage/Remove"); ErrorModel.IsOpen = true; ErrorModel.ErrorContext = e.StackTrace; ErrorModel.ErrorMessage = e.Message; IsFailed = true; StateHasChanged(); } } }
public SMTPSettingItemViewModel Create(SMTPSettingItemViewModel item) { var newItem = repo.Create(item.Item); return(Convert(newItem)); }
public void Delete(SMTPSettingItemViewModel item) { var x = repo.FindById(item.SMTPSettingId); repo.Remove(x); }
public void CreateItem() { currentItem = new SMTPSettingItemViewModel(); EditViewModel.Model = currentItem; EditViewModel.DialogIsOpen = true; }
protected void Edit(SMTPSettingItemViewModel r) { currentItem = (SMTPSettingItemViewModel)r.Clone(); EditViewModel.Model = currentItem; EditViewModel.DialogIsOpen = true; }