public async Task <IActionResult> Add(ClientDto client) { if (ModelState.IsValid) { _appDBContext.Clients.Add(client.ToEntity()); await _appDBContext.SaveChangesAsync(); } return(Json(new { success = true, message = "Запись сохранена успешно" })); }
public async Task <IActionResult> Edit(ClientDto client) { if (ModelState.IsValid) { var record = _appDBContext.Clients.Where(x => x.Id == client.ClientId).FirstOrDefault(); record.INN = client.INN; record.IsBlackListed = client.IsBlackListed; record.LegalAddress = client.LegalAddress; record.MailingAddress = client.MailingAddress; record.Name = client.ClientName; record.ActualAddress = client.ActualAddress; record.Type = client.TypeClient; record.Country = client.Country; _appDBContext.Clients.Update(record); await _appDBContext.SaveChangesAsync(); } return(Json(new { success = true, message = "Запись изменена успешно" })); }