public async Task Update(Saleschannel obj) { bool hasAny = await _context.Saleschannel.AnyAsync(x => x.Id == obj.Id); if (!hasAny) { throw new NotFoundException("Id not found"); } try { _context.Update(obj); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException e) { throw new DbConcurrencyException(e.Message); } }
public async Task <IActionResult> Edit(int id, Saleschannel Saleschannel) { if (id != Saleschannel.Id) { return(BadRequest()); } try { await _SaleschannelService.Update(Saleschannel); return(RedirectToAction(nameof(Index))); } catch (NotFoundException) { return(NotFound()); } catch (DbConcurrencyException) { return(BadRequest()); } }
public async Task InsertAsync(Saleschannel obj) { _context.Add(obj); await _context.SaveChangesAsync(); }
public async Task <IActionResult> Create(Saleschannel Saleschannel) { await _SaleschannelService.InsertAsync(Saleschannel); return(RedirectToAction(nameof(Index))); }