public void Execute(KategorijaWithIdDto request) { var jednaKategorija = _context.Kategorije.Find(request.Id); if (_context.Kategorije.Any(x => x.Id == request.Id)) { if (request.Naziv == jednaKategorija.Naziv) { var jednaKategorijaUpdate = _context.Kategorije.Find(request.Id); jednaKategorijaUpdate.Naziv = request.Naziv; _context.SaveChanges(); } else { if (_context.Kategorije.Any(x => x.Naziv == request.Naziv)) { throw new ConflictException(request.Naziv, typeof(Kategorija)); } else { if (request.Naziv == null) { throw new NotFoundException(request.Id, typeof(Kategorija)); } else { var jednaKategorijaUpdate = _context.Kategorije.Find(request.Id); jednaKategorijaUpdate.Naziv = request.Naziv; _context.SaveChanges(); } } } } else { throw new NotFoundException(request.Id, typeof(Kategorija)); } }
public void Put([FromForm] KategorijaWithIdDto dto, [FromServices] IUpdateKategorijaCommand command) { executor.ApplayCommand(command, dto); }