public Model.Sastanci Delete(int id, SastanciInsertRequest request) { var entity = _context.Sastanci.Find(id); request.IsDeleted = true; _mapper.Map(request, entity); _context.SaveChanges(); return(_mapper.Map <Model.Sastanci>(entity)); }
public Model.Sastanci Update(int id, SastanciInsertRequest request) { var entity = _context.Sastanci.Find(id); _mapper.Map(request, entity); entity.IsDeleted = false; _context.SaveChanges(); if (request.Odobreno == true) { var advokat = _context.Korisnici.AsQueryable().Where(x => x.KorisnikId.Equals(request.ZaposleniciId)); var tempAdvokat = advokat.FirstOrDefault(); var klijent = _context.Korisnici.AsQueryable().Where(x => x.KorisnikId.Equals(request.KlijentId)); var tempKlijent = klijent.FirstOrDefault(); string emailToKlijent = tempKlijent.Email; string emailFromAdvokat = tempAdvokat.Email; var query = _context.Sastanci.AsQueryable().Include(c => c.Klijent).Include(z => z.Zaposlenici).Where(x => x.KlijentId.Equals(request.KlijentId)); var temp = query.FirstOrDefault(); string subject = "Sastanak"; string body = "Sastanak vam je odobren."; string FromMail = "*****@*****.**"; string emailTo = emailToKlijent; MailMessage mail = new MailMessage(); SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com"); mail.From = new MailAddress(FromMail); mail.To.Add(emailTo); mail.Subject = subject; mail.Body = body; SmtpServer.Port = 587; SmtpServer.UseDefaultCredentials = false; SmtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", "Rstest123456"); SmtpServer.EnableSsl = true; SmtpServer.Send(mail); } return(_mapper.Map <Model.Sastanci>(entity)); }
public Model.Sastanci ZakaziSastanak(SastanciInsertRequest request) { request.IsDeleted = false; var entity = _mapper.Map <Database.Sastanci>(request); _context.Sastanci.Add(entity); _context.SaveChanges(); var advokat = _context.Korisnici.AsQueryable().Where(x => x.KorisnikId.Equals(request.ZaposleniciId)); var tempAdvokat = advokat.FirstOrDefault(); var klijent = _context.Korisnici.AsQueryable().Where(x => x.KorisnikId.Equals(request.KlijentId)); var tempKlijent = klijent.FirstOrDefault(); string emailFromKlijent = tempKlijent.Email; string emailToAdvokat = tempAdvokat.Email; var query = _context.Sastanci.AsQueryable().Include(c => c.Klijent).Include(z => z.Zaposlenici).Where(x => x.KlijentId.Equals(request.KlijentId)); var temp = query.FirstOrDefault(); string subject = "Sastanak"; string body = "Klijent " + tempKlijent.Ime + " " + tempKlijent.Prezime + " želi da sa vama da zakaže sastanak dana " + request.DatumSastanka.ToShortDateString(); string FromMail = "*****@*****.**"; string emailTo = emailToAdvokat; MailMessage mail = new MailMessage(); SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com"); mail.From = new MailAddress(FromMail); mail.To.Add(emailTo); mail.Subject = subject; mail.Body = body; SmtpServer.Port = 587; SmtpServer.UseDefaultCredentials = false; SmtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", "Rstest123456"); SmtpServer.EnableSsl = true; SmtpServer.Send(mail); return(_mapper.Map <Model.Sastanci>(entity)); }
public Model.Sastanci Insert(SastanciInsertRequest request) { request.IsDeleted = false; var entity = _mapper.Map <Database.Sastanci>(request); _context.Sastanci.Add(entity); _context.SaveChanges(); var query = _context.Sastanci.AsQueryable().Include(c => c.Klijent).Include(z => z.Zaposlenici).Where(x => x.KlijentId.Equals(request.KlijentId)); var temp = query.FirstOrDefault(); string subject = "Sastanak"; string body = "Novi sastanak je dodan u vaš raspored na dan " + request.DatumSastanka.ToShortDateString(); string FromMail = "*****@*****.**"; //string FromMail = "*****@*****.**"; string emailFormKlijent = temp.Klijent.Email; string emailTo = emailFormKlijent; MailMessage mail = new MailMessage(); SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com"); mail.From = new MailAddress(FromMail); mail.To.Add(emailTo); mail.Subject = subject; mail.Body = body; SmtpServer.Port = 587; SmtpServer.UseDefaultCredentials = false; SmtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", "Rstest123456"); SmtpServer.EnableSsl = true; SmtpServer.Send(mail); return(_mapper.Map <Model.Sastanci>(entity)); }
public Model.Sastanci ZakaziSastanak(SastanciInsertRequest request) { return(_sastanciService.ZakaziSastanak(request)); }
public Model.Sastanci Delete(int id, SastanciInsertRequest request) { return(_sastanciService.Delete(id, request)); }
public Model.Sastanci Insert(SastanciInsertRequest request) { return(_sastanciService.Insert(request)); }
private async void BtnSacuvaj_Click(object sender, EventArgs e) { bool odrzano = false; if (radioButtonDA.Checked) { odrzano = true; } else { odrzano = false; } bool odobreno; if (checkBox1.Checked) { odobreno = true; } else { odobreno = false; } if (this.ValidateChildren()) { int.Parse(cmbVrstaUsluge.SelectedValue.ToString()); var request = new SastanciInsertRequest() { ZaposleniciId = int.Parse(cbZaposlenik.SelectedValue.ToString()), KlijentId = int.Parse(cbKlijent.SelectedValue.ToString()), DatumSastanka = dtpDatumSastanka.Value, MjestoOdrzavanja = txtMjestoOdrzavanja.Text, Poruka = txtPoruka.Text, Odrzan = odrzano, IsDeleted = false, Odobreno = odobreno, VrstaId = int.Parse(cmbVrstaUsluge.SelectedValue.ToString()) }; if (_id.HasValue) { await _aPIServiceSastanci.Update <Model.Sastanci>(_id, request); MessageBox.Show(Properties.Resources.MessageBoxForSave); this.Hide(); frm2.RefreshData(); } else { await _aPIServiceSastanci.Insert <Model.Sastanci>(request); MessageBox.Show(Properties.Resources.MessageBoxForSave); this.Hide(); frmSastanci frm = new frmSastanci(); frm.Show(); if (request.Odobreno == true) { var klijent = await _serviceZaposlenici.GetById <Model.Korisnici>(request.KlijentId); var zaposlenik = await _serviceZaposlenici.GetById <Model.Korisnici>(request.ZaposleniciId); string subject = "Sastanak"; string body = "Odobren vam je sastanak"; string FromMail = "*****@*****.**"; string tempKlijent = klijent.Email; string tempZaposlenik = zaposlenik.Email; MailMessage mail = new MailMessage(); SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com"); mail.From = new MailAddress(FromMail); mail.To.Add(tempKlijent); mail.To.Add(tempZaposlenik); mail.Subject = subject; mail.Body = body; SmtpServer.Port = 587; SmtpServer.UseDefaultCredentials = false; SmtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", "Rstest123456"); SmtpServer.EnableSsl = true; SmtpServer.Send(mail); } } } }
private async void BtnOdobri_Click(object sender, EventArgs e) { var id = dgvSastanci.SelectedRows[0].Cells[0].Value; var entity = await _aPIService.GetById <Model.Sastanci>(id); var klijent = await _aPIServiceZaposlenici.GetById <Model.Korisnici>(entity.KlijentId); var zaposlenik = await _aPIServiceZaposlenici.GetById <Model.Korisnici>(entity.ZaposleniciId); if (entity.Odobreno == false) { try { var request = new SastanciInsertRequest() { ZaposleniciId = entity.ZaposleniciId, MjestoOdrzavanja = entity.MjestoOdrzavanja, KlijentId = entity.KlijentId, DatumSastanka = entity.DatumSastanka, Poruka = entity.Poruka, Odobreno = true, Odrzan = entity.Odrzan, IsDeleted = entity.IsDeleted, VrstaId = entity.VrstaId }; await _aPIService.Update <Model.Sastanci>(id, request); string subject = "Sastanak"; string body = "Odobren vam je sastanak"; string FromMail = "*****@*****.**"; string tempKlijent = klijent.Email; string tempZaposlenik = zaposlenik.Email; MailMessage mail = new MailMessage(); SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com"); mail.From = new MailAddress(FromMail); mail.To.Add(tempKlijent); mail.To.Add(tempZaposlenik); mail.Subject = subject; mail.Body = body; SmtpServer.Port = 587; SmtpServer.UseDefaultCredentials = false; SmtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", "Rstest123456"); SmtpServer.EnableSsl = true; SmtpServer.Send(mail); MessageBox.Show("Uspješno odobreno"); RefreshData(); } catch (Exception) { MessageBox.Show("Operacija neuspješna"); } } else { MessageBox.Show("Korisniku je već sastanak odobren!"); } }