示例#1
0
        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));
        }
示例#2
0
        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));
        }