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)); }
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)); } }
public TuristickaAgencija.Model.PutniciKorisnici Update(int id, [FromBody] PutniciKorisniciInsertRequest request) { return(_service.Update(id, request)); }
public TuristickaAgencija.Model.PutniciKorisnici Insert(PutniciKorisniciInsertRequest request) { return(_service.Insert(request)); }