public Wellness.Model.Osoba Insert(OsobaInsertRequest request) { var entity = _mapper.Map <Wellness.WebAPI.Database.Osoba>(request); if (request.Password != request.PasswordPotvrda) { throw new Exception("Passwordi se ne slažu"); } entity.LozinkaSalt = GenerateSalt(); entity.LozinkaHash = GenerateHash(entity.LozinkaSalt, request.Password); _context.Osoba.Add(entity); _context.SaveChanges(); /* * foreach (var uloga in request.Uloge) * { * Wellness.WebAPIDatabase.KorisniciUloge korisniciUloge = new Database.KorisniciUloge(); * korisniciUloge.KorisnikId = entity.KorisnikId; * korisniciUloge.UlogaId = uloga; * korisniciUloge.DatumIzmjene = DateTime.Now; * _context.KorisniciUloge.Add(korisniciUloge); * } * _context.SaveChanges(); */ entity = _context.Osoba.Where(o => o.Id == entity.Id) .Include(o => o.Uloga) .FirstOrDefault(); return(_mapper.Map <Wellness.Model.Osoba>(entity)); }
public Model.Osoba Update(int id, OsobaInsertRequest request) { var osoba = _context.Osoba.Where(o => o.Id == id) .Include(o => o.Uloga) .FirstOrDefault(); _mapper.Map(request, osoba); _context.SaveChanges(); return(_mapper.Map <Model.Osoba>(osoba)); }
public Model.Osoba Update(int id, OsobaInsertRequest request) { return(_service.Update(id, request)); }
private void bttnDodajScenaristuDodaj_Click(object sender, EventArgs e) { if (cbxListGlumaca.SelectedIndex != 0) { if (_filmscenaristiService.Get <List <FilmScenaristi> >(new FilmScenaristiSearchRequest { FilmId = _filmId, ScenaristId = (int)cbxListGlumaca.SelectedValue }).Select(s => s.ScenaristId).ToList().Count != 0) { OcistiTextBoxove(); return; } var g = _glumacService.Get <List <Osoba> >(new OsobaSearchRequest { OsobaId = ((int)cbxListGlumaca.SelectedValue) }).FirstOrDefault(); //_glumacService.GetById<Osoba>((int)cbxListGlumaca.SelectedValue); _filmscenaristiService.Add(new FilmScenaristiInsertRequest { FilmId = _filmId, ScenaristId = g.Id }); var l = new LinkLabel { Text = g.Ime + " " + g.Prezime }; pnlScenaristi.RowStyles.Add(new RowStyle(SizeType.AutoSize)); pnlScenaristi.Controls.Add(l); //l.Dock = DockStyle.Fill; l.Anchor = AnchorStyles.Left; l.TextAlign = ContentAlignment.MiddleCenter; OcistiTextBoxove(); } else { if (this.ValidateChildren(ValidationConstraints.Enabled)) { var g = new OsobaInsertRequest { Ime = txtIme.Text, Prezime = txtPrezime.Text, Biografija = txtBiografija.Text, DatumRodjenja = dtpDatum.Value, GradId = (int)cbxGrad.SelectedValue, UlogaId = _ulogaService.Get <List <Uloga> >(new UlogaSearchRequest { NazivUloge = "Scenarista" }).Select(s => s.Id).FirstOrDefault() // _ulogaService.GetByName<Uloga>("Scenarista").Id }; var gl = _glumacService.Add <OsobaInsertRequest>(g); var gId = _glumacService.Get <List <Osoba> >(new OsobaSearchRequest { Ime = g.Ime, Prezime = g.Prezime }).Select(s => s.Id).FirstOrDefault(); _filmscenaristiService.Add(new FilmScenaristiInsertRequest { FilmId = _filmId, ScenaristId = gId }); var l = new LinkLabel { Text = g.Ime + " " + g.Prezime }; pnlScenaristi.RowStyles.Add(new RowStyle(SizeType.AutoSize)); pnlScenaristi.Controls.Add(l); //l.Dock = DockStyle.Fill; l.Anchor = AnchorStyles.Left; l.TextAlign = ContentAlignment.MiddleCenter; OcistiTextBoxove(); } } }
public Model.Osoba Insert(OsobaInsertRequest request) { return(_service.Insert(request)); }