public KundeItemViewModel Create(KundeItemViewModel item) { item.ConfigurationJson = JsonSerializer.Serialize(item.ConfModel); var newItem = repo.Create(item.Item); return(Convert(newItem)); }
public void Update(KundeItemViewModel item) { var x = repo.FindById(item.KundeId); x.KundeId = item.KundeId; x.KundeName = item.KundeName; x.KundeNR = item.KundeNR; x.ConfigurationJson = JsonSerializer.Serialize(item.ConfModel); repo.Update(x); }
protected void Save(KundeItemViewModel item) { try { if (item.KundeId > 0) { Service.Update(item); var index = Model.FindIndex(x => x.KundeId == this.currentItem.KundeId); Model[index] = item; StateHasChanged(); } else { if (Model.Count() > 0) { item.KundeId = Model.Select(r => r.KundeId).Max() + 1; } else { item.KundeId = 1; } var newItem = Service.Create(item); if (newItem != null) { Model.Add(newItem); } } StateHasChanged(); } catch (Exception e) { Logger.LogError(e, $"{GetUserName()}*Error: KundePage/Save"); ErrorModel.IsOpen = true; ErrorModel.ErrorContext = e.StackTrace; ErrorModel.ErrorMessage = e.Message; IsFailed = true; StateHasChanged(); } }
protected async Task OpenConfirmServiceRemove(KundeItemViewModel item) { var result = await MatDialogService.AskAsync("Are you sure?", new string[] { "Yes", "No" }); if (result == "Yes") { try { Service.Delete(item); Model.Remove(item); } catch (Exception e) { Logger.LogError(e, $"{GetUserName()}*Error: KundePage/Remove"); ErrorModel.IsOpen = true; ErrorModel.ErrorContext = e.StackTrace; ErrorModel.ErrorMessage = e.Message; IsFailed = true; StateHasChanged(); } } }
public void CreateItem() { currentItem = new KundeItemViewModel(); EditViewModel.Model = currentItem; EditViewModel.DialogIsOpen = true; }
protected void Edit(KundeItemViewModel r) { currentItem = (KundeItemViewModel)r.Clone(); EditViewModel.Model = currentItem; EditViewModel.DialogIsOpen = true; }
public void Delete(KundeItemViewModel item) { var x = repo.FindById(item.KundeId); repo.Remove(x); }