예제 #1
0
        public TuristickaAgencija.Model.PutniciKorisnici Insert(PutniciKorisniciInsertRequest request)
        {
            var entity = _mapper.Map <Database.PutniciKorisnici>(request);


            if (request.Password != request.PasswordPotvrda)

            {
                throw new Exception("Passwordi se ne slažu");
            }

            entity.LozinkaSalt = GenerateSalt();

            entity.LozinkaHash = GenerateHash(entity.LozinkaSalt, request.Password);


            _db.PutniciKorisnici.Add(entity);

            _db.SaveChanges();

            _db.SaveChanges();


            return(_mapper.Map <TuristickaAgencija.Model.PutniciKorisnici>(entity));
        }
예제 #2
0
        public TuristickaAgencija.Model.PutniciKorisnici Update(int id, PutniciKorisniciInsertRequest request)
        {
            {
                var entity = _db.PutniciKorisnici.Where(x => x.PutnikKorisnikId == id).FirstOrDefault();

                _db.PutniciKorisnici.Attach(entity);

                _db.PutniciKorisnici.Update(entity);


                if (!string.IsNullOrWhiteSpace(request.Password))

                {
                    if (request.Password != request.PasswordPotvrda)

                    {
                        throw new Exception("Passwordi se ne slažu");
                    }

                    entity.LozinkaSalt = GenerateSalt();

                    entity.LozinkaHash = GenerateHash(entity.LozinkaSalt, request.Password);
                }

                _mapper.Map(request, entity);


                _db.SaveChanges();


                return(_mapper.Map <TuristickaAgencija.Model.PutniciKorisnici>(entity));
            }
        }
예제 #3
0
        public TuristickaAgencija.Model.PutniciKorisnici Update(int id, [FromBody] PutniciKorisniciInsertRequest request)

        {
            return(_service.Update(id, request));
        }
예제 #4
0
        public TuristickaAgencija.Model.PutniciKorisnici Insert(PutniciKorisniciInsertRequest request)

        {
            return(_service.Insert(request));
        }