private async void btnLogin_Click(object sender, EventArgs e) { try { if (string.IsNullOrWhiteSpace(txtUsername.Text) || string.IsNullOrWhiteSpace(txtPassword.Text)) { MessageBox.Show("Obavezno unesite korisničko ime i lozinku!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } var request = new UserSearchRequest() { username = txtUsername.Text }; APIService.Username = txtUsername.Text; APIService.Password = txtPassword.Text; var user = await _userService.Get <List <Data.Model.Users> >(request); var obj = user.First(); if (obj.RoleID == 2) { MessageBox.Show("Administrator sa unesenim kredencijalima ne postoji!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { MessageBox.Show("Uspješno ste se logovali!", "Uspješna prijava", MessageBoxButtons.OK, MessageBoxIcon.Information); } CarServiceSearchRequest req = new CarServiceSearchRequest() { userID = obj.UserID }; var listCS = await _carService.Get <List <Data.Model.CarService> >(req); var objCS = listCS.First(); frmCarServiceMainMenu frmCS = new frmCarServiceMainMenu(objCS.CarServiceID); frmCS.Show(); this.Hide(); } catch (Exception err) { MessageBox.Show(err.Message, "Pogrešno korisničko ime ili lozinka!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public List <Data.Model.CarService> Get(CarServiceSearchRequest request) { var query = _context.CarServices.AsQueryable(); if (request.userID == 0) { var list1 = query.ToList(); return(_mapper.Map <List <Data.Model.CarService> >(list1)); } if (request.userID.HasValue) { query = query.Where(c => c.UserID == request.userID); } var list = query.ToList(); return(_mapper.Map <List <Data.Model.CarService> >(list)); }
public List <Data.Model.CarService> Get([FromQuery] CarServiceSearchRequest request) { return(_service.Get(request)); }