public Clanovi Insert(ClanUpsertRequest request) { var entity = _mapper.Map <Database.Clan>(request); var nalogId = _korisnickiNalogService.Insert(request).KorisnickiNalogId; entity.KorisnickiNalogId = nalogId; entity.GradId = request.GradId; entity.DatumRegistracije = DateTime.Now; _context.Clan.Add(entity); _context.SaveChanges(); return(_mapper.Map <Model.Clanovi>(entity)); }
public Korisnici Insert(KorisniciUpsertRequest request) { var entity = _mapper.Map <Database.Korisnik>(request); var nalogId = _korisnickiNalogService.Insert(request).KorisnickiNalogId; entity.KorisnickiNalogId = nalogId; _context.Korisnik.Add(entity); _context.SaveChanges(); foreach (var licenca in request.Licence) { _context.TrenerLicence.Add(new Database.TrenerLicence() { KorisnikId = entity.KorisnikId, LicencaId = licenca }); } _context.SaveChanges(); return(_mapper.Map <Model.Korisnici>(entity)); }