public Model.Gradovi Insert(GradoviInsertRequest request) { Database.Gradovi entity = _mapper.Map <Database.Gradovi>(request); _context.Gradovi.Add(entity); _context.SaveChanges(); return(_mapper.Map <Model.Gradovi>(entity)); }
public Model.Gradovi Update(int id, GradoviInsertRequest request) { Database.Gradovi entity = _context.Gradovi.Where(x => x.GradId == id).FirstOrDefault(); _context.Gradovi.Attach(entity); _context.Gradovi.Update(entity); entity = _mapper.Map(request, entity); _context.SaveChanges(); return(_mapper.Map <Model.Gradovi>(entity)); }