Esempio n. 1
0
        public virtual TModel Insert(TInsert req)
        {
            var t = _mapper.Map <TDatabase>(req);

            _context.Add(t);
            _context.SaveChanges();
            return(_mapper.Map <TModel>(t));
        }
        public Model.Korisnik Insert(KorisniciInsertRequest request)
        {
            var entity = _mapper.Map <Database.Korisnici>(request);

            if (request.lozinka != request.potvrdaLozinke)
            {
                throw new Exception("Passwordi se ne slažu");
            }

            entity.LozinkaSalt = GenerateSalt();
            entity.LozinkaHash = GenerateHash(entity.LozinkaSalt, request.lozinka);

            _context.Korisnici.Add(entity);
            _context.SaveChanges();

            return(_mapper.Map <Model.Korisnik>(entity));
        }