public IHttpActionResult IzradiKupac(KupacDto kupacDto) { if (!ModelState.IsValid) { return(BadRequest()); } var kupac = Mapper.Map <KupacDto, Kupac>(kupacDto); _context.Kupci.Add(kupac); _context.SaveChanges(); kupacDto.Id = kupac.Id; return(Created(new Uri(Request.RequestUri + "/" + kupac.Id), kupacDto)); }
public IHttpActionResult AzurirajKupac(int id, KupacDto kupacDto) { if (!ModelState.IsValid) { return(BadRequest()); } var kupacUDb = _context.Kupci.SingleOrDefault(c => c.Id == id); if (kupacUDb == null) { return(NotFound()); } Mapper.Map(kupacDto, kupacUDb); _context.SaveChanges(); return(Ok()); }