/// <summary> /// Добавить или отредактировать /// </summary> protected async Task AddAsync() { //Получаем id услуги int idService = int.Parse(ProviderServiceModel.IdService); //Проверяем, существует ли текущая модель if (providersServices == null) { //Создаем и инициализируем модель providersServices = new ProvidersServices() { IdProvider = Provider.IdProvider, IdService = idService }; //Записываем модель в БД await Repository.AddAsync(providersServices); } else { //Меняем модель и записываем изменения в БД providersServices.IdService = idService; await Repository.EditAsync(providersServices); } CloseModal(); await StateUpdate(); }
/// <summary> /// Изменить запись /// </summary> protected void Edit(ProvidersServices item) { //Готовим модель представления isUpdate = true; providersServices = item; OpenModal(); ProviderServiceModel.IdService = providersServices.IdService.ToString(); }
protected void CloseModal() { providersServices = default; isUpdate = false; modal.Close(); }
/// <summary> /// Удалить запись /// </summary> /// <param name="item"></param> protected async Task RemoveAsync(ProvidersServices item) { await Repository.RemoveAsync(item.Id); await StateUpdate(); }