public async Task Init() { var search = new PredmetiSearchRequest { DatumOd = DatumOd, DatumDo = DatumDo }; var list = await _predmetiService.Get <List <Predmeti> >(search); //List<RadniSati> listaRadnihSati = new List<RadniSati>(); //foreach(var l in list) //{ // listaRadnihSati = await _radniSatiService.Get<List<RadniSati>>(l.BrojPredmeta); //} PredmetiList.Clear(); foreach (var predmeti in list) { PredmetiList.Add(predmeti); } }
private async void TxtPretraga_TextChanged(object sender, EventArgs e) { var search = new PredmetiSearchRequest { BrojPredmeta = txtPretraga.Text }; var result = await _aPIService.Get <List <Model.Predmeti> >(search); dgvPredmeti.DataSource = result; }
public List <Model.Predmeti> Get2(PredmetiSearchRequest request) { var predmeti = _context.Predmeti.ToList(); var troskovi = _context.Troskovi.ToList(); List <Database.Predmeti> listPredmetaSaNulaTransakcija = new List <Database.Predmeti>(); decimal countTransakcije = 0; bool transakcijeVeceODNula = false; foreach (var p in predmeti) { countTransakcije = 0; transakcijeVeceODNula = false; foreach (var t in troskovi) { if (p.PredmetId == t.PredmetID && t.Iznos == 0 && p.RokUplate < DateTime.Now) { listPredmetaSaNulaTransakcija.Add(p); //salji mail } if (p.PredmetId == t.PredmetID) { countTransakcije += t.Iznos; } if (p.PredmetId == t.PredmetID && t.Iznos > 0 && p.RokUplate < DateTime.Now) { transakcijeVeceODNula = true; } } if (countTransakcije < p.UkupniTrosak && transakcijeVeceODNula) { //salji mail } } var datum = DateTime.MinValue; if (request.DatumOd.Date != datum.Date && request.DatumDo.Date != datum.Date) { // query = query.Where(x => x.DatumPocetka >= request.DatumOd && x.DatumPocetka <= request.DatumDo).Include(c => c.Zaposlenici).Include(k => k.Klijent).Include(s => s.Status).Include(v => v.VrstaUsluge); } // query = query.Where(p => p.IsDeleted == false).Include(k => k.Klijent).Include(s => s.Status).Include(v => v.VrstaUsluge); var list = listPredmetaSaNulaTransakcija.ToList(); return(_mapper.Map <List <Model.Predmeti> >(list)); }
public List <Model.Predmeti> GetTodayPredmeti(PredmetiSearchRequest request) { var query = _context.Predmeti.AsQueryable().Include(c => c.Zaposlenici).Include(k => k.Klijent).Include(s => s.Status).Include(v => v.VrstaUsluge); query = query.Where(x => x.DatumPocetka.Date == DateTime.Now.Date).Include(c => c.Zaposlenici).Include(k => k.Klijent).Include(s => s.Status).Include(v => v.VrstaUsluge); query = query.Where(p => p.IsDeleted == false).Include(k => k.Klijent).Include(s => s.Status).Include(v => v.VrstaUsluge); var list = query.ToList(); return(_mapper.Map <List <Model.Predmeti> >(list)); }
public bool GetTroskovi([FromQuery] PredmetiSearchRequest request) { List <Model.Predmeti> lista = new List <Model.Predmeti>(); lista = _predmetiService.Get(request); foreach (var p in lista) { if (p.UkupniTrosak == 0) { int result = DateTime.Compare((DateTime)p.RokUplate, DateTime.Now); if (result < 0) { //send email } } } return(true); }
public async Task Init() { var search = new PredmetiSearchRequest { DatumOd = DatumOd, DatumDo = DatumDo }; var list = await _predmetiService.Get <List <Predmeti> >(search); List <RadniSati> listaRadnihSati = new List <RadniSati>(); foreach (var l in list) { listaRadnihSati = await _radniSatiService.Get <List <RadniSati> >(l.BrojPredmeta); } decimal suma = 0; foreach (var l in list) { foreach (var r in listaRadnihSati) { if (l.BrojPredmeta == r.BrojPredmeta) { l.Ukupno += r.BrojRadnihSati * r.CijenaPoSatu; suma += l.Ukupno; } } } Total = suma; PredmetiList.Clear(); foreach (var predmeti in list) { PredmetiList.Add(predmeti); } }
public List <Model.Predmeti> Get(PredmetiSearchRequest request) { var query = _context.Predmeti.AsQueryable().Include(c => c.Zaposlenici).Include(k => k.Klijent).Include(s => s.Status).Include(v => v.VrstaUsluge); if (!string.IsNullOrWhiteSpace(request?.BrojPredmeta)) { query = query.Where(x => x.BrojPredmeta.StartsWith(request.BrojPredmeta)).Include(c => c.Zaposlenici).Include(k => k.Klijent).Include(s => s.Status).Include(v => v.VrstaUsluge); } var datum = DateTime.MinValue; if (request.DatumOd.Date != datum.Date && request.DatumDo.Date != datum.Date) { query = query.Where(x => x.DatumPocetka >= request.DatumOd && x.DatumPocetka <= request.DatumDo).Include(c => c.Zaposlenici).Include(k => k.Klijent).Include(s => s.Status).Include(v => v.VrstaUsluge); } query = query.Where(p => p.IsDeleted == false).Include(k => k.Klijent).Include(s => s.Status).Include(v => v.VrstaUsluge); var list = query.ToList(); return(_mapper.Map <List <Model.Predmeti> >(list)); }
private void tmrExecutor_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { ServiceLog.WriteErrorLog("sadsfasfasf"); //Do your Sending email work here try { ServiceLog.WriteErrorLog("doslo"); var predmeti = new List <Advokati.Model.Predmeti>(); var troskovi = new List <Advokati.Model.Troskovi>(); PredmetiSearchRequest request = new PredmetiSearchRequest(); TroskoviSearchRequest request2 = new TroskoviSearchRequest(); ServiceLog.WriteErrorLog("doslo 11"); HttpClient client = new HttpClient(); client.BaseAddress = new Uri(URL); // Add an Accept header for JSON format. client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); // List data response. HttpResponseMessage response = client.GetAsync("predmeti").Result; // Blocking call! Program will wait here until a response is received or a timeout occurs. if (response.IsSuccessStatusCode) { // Parse the response body. // var responseAsString = response.Content.ReadAsAsync(); // ServiceLog.WriteErrorLog(responseAsString.ToString()); //Advokati.Model.Predmeti responseAsConcreteType = JsonConvert.DeserializeObject<Advokati.Model.Predmeti>(responseAsString); predmeti = response.Content.ReadAsAsync <List <Advokati.Model.Predmeti> >().Result; //Make sure to add a reference to System.Net.Http.Formatting.dll //ServiceLog.WriteErrorLog("response"); //ServiceLog.WriteErrorLog(predmeti.Count.ToString()); //foreach (var d in predmeti) //{ // ServiceLog.WriteErrorLog("d"); // ServiceLog.WriteErrorLog(d.ToString()); //} } else { Console.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase); } HttpResponseMessage response1 = client.GetAsync("troskovi").Result; // Blocking call! Program will wait here until a response is received or a timeout occurs. if (response1.IsSuccessStatusCode) { // Parse the response body. // var responseAsString = response.Content.ReadAsAsync(); // ServiceLog.WriteErrorLog(responseAsString.ToString()); //Advokati.Model.Predmeti responseAsConcreteType = JsonConvert.DeserializeObject<Advokati.Model.Predmeti>(responseAsString); troskovi = response1.Content.ReadAsAsync <List <Advokati.Model.Troskovi> >().Result; //Make sure to add a reference to System.Net.Http.Formatting.dll //ServiceLog.WriteErrorLog("Troskovi"); //ServiceLog.WriteErrorLog(troskovi.Count.ToString()); //foreach (var d in troskovi) //{ // ServiceLog.WriteErrorLog("tr"); // ServiceLog.WriteErrorLog(d.ToString()); //} } else { Console.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase); } //Advokati.WebAPI.Services.PredmetiService. //var predmeti = _predmetiService.Get(request); //ServiceLog.WriteErrorLog("doslo1"); //ar troskovi = _troskoviService.Get(request2); List <Advokati.Model.Predmeti> listPredmetaSaNulaTransakcija = new List <Advokati.Model.Predmeti>(); ServiceLog.WriteErrorLog("doslo2"); decimal countTransakcije = 0; bool transakcijeVeceODNula = false; foreach (var p in predmeti) { countTransakcije = 0; transakcijeVeceODNula = false; foreach (var t in troskovi) { if (p.PredmetId == t.PredmetID && t.Iznos == 0 && p.RokUplate < DateTime.Now) { ServiceLog.WriteErrorLog("prvi if"); listPredmetaSaNulaTransakcija.Add(p); ServiceLog.SendEmail(p); } if (p.PredmetId == t.PredmetID) { countTransakcije += t.Iznos; } if (p.PredmetId == t.PredmetID && t.Iznos > 0 && p.RokUplate < DateTime.Now) { transakcijeVeceODNula = true; } } if (countTransakcije < p.UkupniTrosak && transakcijeVeceODNula) { ServiceLog.WriteErrorLog("drugi if"); ServiceLog.SendEmail(p); } } } catch (Exception exc) { ServiceLog.WriteErrorLog(exc); // Block of code to handle errors } // SastanciSearchRequest request = new SastanciSearchRequest(); //List<Advokati.Model.Sastanci> sastanci = _sastanciService.Get(request); //ovdje sad treba izvrtiti sastanke ili bilo sta i zavisnosti od datuma slati mailove }
public List <Model.Predmeti> Get([FromQuery] PredmetiSearchRequest request) { return(_predmetiService.Get(request)); // return _predmetiService.Get2(request); }
public List <Model.Predmeti> todayPredmeti([FromQuery] PredmetiSearchRequest request) { return(_predmetiService.GetTodayPredmeti(request)); }