Exemplo n.º 1
0
 public Person GetById(Guid id)
 {
     using (var connection = context.CreateConnection())
     {
         return(connection.Query <Person>(PersonQuery.ById(id)).SingleOrDefault());
     }
 }
Exemplo n.º 2
0
        public void Delete(int id)
        {
            var entity = new PersonQuery().Get(id);

            SessionFactoryHelper.CurrentSession.Delete(entity);
            SessionFactoryHelper.CurrentSession.Flush();
        }
        protected override Response <IPerson> PerformQuery()
        {
            var client      = new Client("ffffffffff");
            var personQuery = new PersonQuery("John", null, "Smith", null, null, "98101");

            return(client.FindPeople(personQuery));
        }
Exemplo n.º 4
0
        public async Task <IEnumerable <GetPersonViewModel> > GetAll()
        {
            var personQuery = new PersonQuery();
            var response    = await _mediator.Send(personQuery);

            return(response.Adapt <IEnumerable <GetPersonViewModel> >());
        }
Exemplo n.º 5
0
 public IEnumerable <Person> GetAll()
 {
     using (var connection = context.CreateConnection())
     {
         return(connection.Query <Person>(PersonQuery.All()));
     }
 }
Exemplo n.º 6
0
        protected override ProApiLibrary.Api.Responses.Response <IPerson> PerformQuery()
        {
            var client = new Client(ClientIntegrationTestHelper.ApiKey);
            var query  = new PersonQuery(EntityId.FromString("Person.3a366a38-d82c-4e0d-a206-12242a881953.Ephemeral"));

            return(client.FindPeople(query));
        }
Exemplo n.º 7
0
        private void SendMessageFromSupervisor(List <Person> recipients)
        {
            var countyGardens =
                new KindergardenQuery {
                City = ((Supervisor)_messageSender).City
            }.GetByFilter().ToList();

            switch (Who.SelectedValue)
            {
            case "גננת":
                var teacher = new PersonQuery().Get(int.Parse(Where.SelectedValue));

                if (teacher != null)
                {
                    recipients.Add(teacher);
                }
                break;

            case "גננות המחוז":

                recipients.AddRange(countyGardens.Select(c => c.Teacher).ToList());
                break;

            case "ילדי המחוז":
                foreach (var kindergarden in countyGardens)
                {
                    recipients.AddRange(kindergarden.Children);
                }
                break;
            }
        }
Exemplo n.º 8
0
 public void Delete(Guid id)
 {
     using (var connection = context.CreateConnection())
     {
         connection.Execute(PersonQuery.Delete(id));
     }
 }
Exemplo n.º 9
0
        public async Task <IEnumerable <PersonDto> > Query()
        {
            var personQuery = new PersonQuery();
            var people      = await dispatcher.Query <PersonQuery, IEnumerable <Person> >(personQuery);

            return(Mapper.Map(people).ToANew <IEnumerable <PersonDto> >());
        }
Exemplo n.º 10
0
 public Person Get(Guid id)
 {
     using (_personQuery = new PersonQuery())
     {
         return(_personQuery.GetById(id));
     }
 }
Exemplo n.º 11
0
        private async Task <bool> TryLoadPersonDetailsAsync()
        {
            // TODO: Better guarding.
            if (PersonDetails != null)
            {
                return(true);
            }

            var provider = ProviderManager.Instance.GlobalProvider;

            if (provider?.State != ProviderState.SignedIn)
            {
                PersonDetails = null;
                return(false);
            }

            var graph = provider.GetClient();

            try
            {
                if (!string.IsNullOrWhiteSpace(UserId))
                {
                    var user = await graph.GetUserAsync(UserId);

                    PersonDetails = user.ToPerson();
                }
                else if (PersonQuery?.ToLowerInvariant() == PersonQueryMe)
                {
                    var user = await graph.GetMeAsync();

                    PersonDetails = user.ToPerson();
                }
                else if (!string.IsNullOrWhiteSpace(PersonQuery))
                {
                    var people = await graph.FindPersonAsync(PersonQuery);

                    if (people != null && people.Count > 0)
                    {
                        PersonDetails = people.FirstOrDefault();
                    }
                }
            }
            catch (Microsoft.Graph.ServiceException e)
            {
                if (e.StatusCode == System.Net.HttpStatusCode.Forbidden)
                {
                    // Insufficient privileges.
                    // Incremental consent must not be supported by the current provider.
                    // TODO: Log or handle the lack of sufficient privileges.
                }
                else
                {
                    // Something unexpected happened.
                    throw;
                }
            }

            return(PersonDetails != null);
        }
Exemplo n.º 12
0
        public int Remove([FromRoute] string id)
        {
            var query = new PersonQuery();

            //return query.Remove(data);

            return(0);
        }
Exemplo n.º 13
0
 public IEnumerable <Person> Get()
 {
     using (_personQuery = new PersonQuery())
     {
         var people = _personQuery.GetAll().ToList();
         return(people);
     }
 }
Exemplo n.º 14
0
 public ProspectServiceImpl(PersonRepository personRepository,
                            PersonQuery personQuery,
                            AccomodationQuery accomodationQuery)
 {
     this.personRepository  = personRepository;
     this.personQuery       = personQuery;
     this.accomodationQuery = accomodationQuery;
 }
Exemplo n.º 15
0
 public Person Update(Person person)
 {
     using (var connection = context.CreateConnection())
     {
         connection.Execute(PersonQuery.Update(person));
         return(person);
     }
 }
Exemplo n.º 16
0
        public async Task <PersonDto> Query(Guid id)
        {
            var query = new PersonQuery {
                Id = id
            };
            var person = await dispatcher.Query <PersonQuery, Person>(query);

            return(Mapper.Map(person).ToANew <PersonDto>());
        }
Exemplo n.º 17
0
        public async Task <IActionResult> DeleteAll()
        {
            await Db.Connection.OpenAsync();

            var query = new PersonQuery(Db);
            await query.DeleteAllAsync();

            return(new OkResult());
        }
Exemplo n.º 18
0
        public async Task <IActionResult> GetLatest()
        {
            await Db.Connection.OpenAsync();

            var query  = new PersonQuery(Db);
            var result = await query.LatestPostsAsync();

            return(new OkObjectResult(result));
        }
 public ClientServiceImpl(PersonRepository personRepository,
     PersonQuery personQuery,
     AccomodationQuery accomodationQuery,
     IMediator mediator)
 {
     this.personRepository = personRepository;
     this.personQuery = personQuery;
     this.accomodationQuery = accomodationQuery;
     this.mediator = mediator;
 }
Exemplo n.º 20
0
        static void Main(string[] args)
        {
            RegisterMappings.Register();

            var categories = new CategoryQuery().GetAll();

            Console.WriteLine("Categories");
            foreach (var category in categories)
            {
                Console.WriteLine($"\t{category.Id} | {category.Description}");
            }

            var people = new PersonQuery().GetAll();

            Console.WriteLine("People and categories");
            foreach (var person in people)
            {
                Console.WriteLine($"\t{person.Id} | {person.Name} | {person.Age} | {person.CategoryId} | {person.Category.Description}");
            }

            var peopleProjects = new PersonQuery().GetAllWithProjects();

            Console.WriteLine("People and projects");
            foreach (var person in peopleProjects)
            {
                Console.WriteLine($"\t{person.Id} | {person.Name}");
                if (person.Projects != null)
                {
                    foreach (var project in person.Projects)
                    {
                        Console.WriteLine($"\t\t{project.Id} | {project.Name}");
                    }
                }
                else
                {
                    Console.WriteLine($"\t\tNo projects");
                }
            }

            var priorities = new PriorityQuery().GetAll();

            Console.WriteLine("Priorities");
            foreach (var priority in priorities)
            {
                Console.WriteLine($"\t{priority.Id} | {priority.Description}");
            }

            var tickets = new TicketQuery().GetAll();

            Console.WriteLine("Tickets");
            foreach (var ticket in tickets)
            {
                Console.WriteLine($"\t{ticket.Description} | {ticket.PersonId} | {(ticket.Person?.Name ?? "No requester")} | {(ticket.Person?.CategoryId.ToString() ?? "No category id")} | {(ticket.Person?.Category?.Description ?? "No category")} | {(ticket.PriorityId.ToString() ?? "No priority Id")} | {(ticket.Priority?.Description ?? "No Priority")}");
            }
        }
Exemplo n.º 21
0
        public async Task <IEnumerable <Person> > Handle(PersonQuery request, CancellationToken cancellationToken)
        {
            var response = await _redisRepository.GetAll <IEnumerable <Person> >("People");

            if (response == null)
            {
                response = await _personRepository.GetAll();

                await _redisRepository.CreateWithData("People", response);
            }
            return(response);
        }
Exemplo n.º 22
0
 private void GetByFilter()
 {
     var query = new PersonQuery
                     {
                         FirstName = FirstNameFilter.Text,
                         LastName = LastNameFilter.Text,
                         IdNum = IdFilter.Text,
                         BirthDate = BirthDate.Text != "" ? DateTime.Parse(BirthDate.Text) : (DateTime?) null
                     };
     EntitiesGrid.DataSource = query.GetByFilter();
     EntitiesGrid.DataBind();
 }
Exemplo n.º 23
0
        private void GetByFilter()
        {
            var query = new PersonQuery
            {
                FirstName = FirstNameFilter.Text,
                LastName  = LastNameFilter.Text,
                IdNum     = IdFilter.Text,
                BirthDate = BirthDate.Text != "" ? DateTime.Parse(BirthDate.Text) : (DateTime?)null
            };

            EntitiesGrid.DataSource = query.GetByFilter();
            EntitiesGrid.DataBind();
        }
Exemplo n.º 24
0
        public Person Create(Person person)
        {
            if (person.Id == Guid.Empty)
            {
                person.Id = Guid.NewGuid();
            }

            using (var connection = context.CreateConnection())
            {
                connection.Execute(PersonQuery.Insert(person));
                return(person);
            }
        }
Exemplo n.º 25
0
        public async Task <IActionResult> GetOne(int id)
        {
            await Db.Connection.OpenAsync();

            var query  = new PersonQuery(Db);
            var result = await query.FindOneAsync(id);

            if (result is null)
            {
                return(new NotFoundResult());
            }
            return(new OkObjectResult(result));
        }
Exemplo n.º 26
0
        public async Task <QueryResult <Person> > GetPersons(PersonQuery queryObj)
        {
            var result = new QueryResult <Person>();

            var query = _context.Persons.AsQueryable();

            //Searching
            if (!String.IsNullOrWhiteSpace(queryObj.SearchTerm))
            {
                query = query.Where(p => p.FirstName.Contains(queryObj.SearchTerm) ||
                                    p.LastName.Contains(queryObj.SearchTerm) ||
                                    p.PersonalNumber.Contains(queryObj.SearchTerm));
            }


            //Filtering
            if (queryObj.Gender.HasValue)
            {
                query = query.Where(p => p.Gender == queryObj.Gender);
            }
            query = query.Where(p =>
                                p.Birthdate.Value.Year >= queryObj.MinYearOfBirth && p.Birthdate.Value.Year <= queryObj.MaxYearOfBirth);


            //Ordering
            var columnsMap = new Dictionary <string, Expression <Func <Person, object> > >()
            {
                ["firstName"] = p => p.FirstName,
                ["lastName"]  = p => p.LastName,
                ["birthdate"] = p => p.Birthdate,
                ["id"]        = p => p.Id
            };

            if (!string.IsNullOrWhiteSpace(queryObj.SortBy) && columnsMap.ContainsKey(queryObj.SortBy))
            {
                query = queryObj.IsSortAscending ? query.OrderBy(columnsMap[queryObj.SortBy]) : query.OrderByDescending(columnsMap[queryObj.SortBy]);
            }
            else
            {
                query = query.OrderBy(p => p.Id);
            }

            result.TotalItems = await query.CountAsync();

            //Paging
            query = query.Skip((queryObj.Page - 1) * queryObj.PageSize).Take(queryObj.PageSize);

            result.Items = await query.ToListAsync();

            return(result);
        }
Exemplo n.º 27
0
        public ActionResult Login(LoginModel loginModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(new LoginModel()));
            }

            var getUserFromDataBase = new PersonQuery().GetFromDatabase(loginModel.EmailId);

            if (getUserFromDataBase.Id == 0)
            {
                ModelState.Clear();
                ModelState.AddModelError("", "Invalid UserName or Password");
                return(View(new LoginModel()));
            }

            var salt = Convert.FromBase64String(getUserFromDataBase.Salt);

            var generatehash = GenerateHash(salt, loginModel.Password);

            if (generatehash == getUserFromDataBase.Password)
            {
                var user = new User()
                {
                    LastName = getUserFromDataBase.LastName, FirstName = getUserFromDataBase.FirstName, EmailId = getUserFromDataBase.EmailId, Id = getUserFromDataBase.Id
                };

                var serializer = new JavaScriptSerializer();

                var userData = serializer.Serialize(user);

                FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(
                    1,
                    user.FullName,
                    DateTime.Now,
                    DateTime.Now.AddMinutes(15),
                    false,
                    userData);

                string     encTicket = FormsAuthentication.Encrypt(authTicket);
                HttpCookie faCookie  = new HttpCookie(FormsAuthentication.FormsCookieName, encTicket);
                Response.Cookies.Add(faCookie);
                TempData["UserMessage"] = new SuccessMessage {
                    CssClassName = "alert alert-success", Title = "Login Successful", Message = "Operation Done."
                };
                return(RedirectToAction("Index", "Home"));
            }
            ModelState.AddModelError("", "Invalid UserName or Password");
            return(View(new LoginModel()));
        }
Exemplo n.º 28
0
        protected void SaveClick(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                var userId = ((Person)Session["CurrentUser"]).Id;
                var user   = new PersonQuery().Get(userId);

                user.Password = NewPassword.Text;
                PersonEdit.Instance.Update(user);

                NewPassword.Text = "";
                ClientScript.RegisterStartupScript(GetType(), "msg", "<script language='javascript'>showMessage()</script>");
            }
        }
Exemplo n.º 29
0
        public void ReadmeExample()
        {
            var client      = new Client(ClientIntegrationTestHelper.ApiKey);
            var personQuery = new PersonQuery("Rory", null, "Williams", null, "WA", null);
            var response    = client.FindPeople(personQuery);

            if (response != null && response.IsSuccess)
            {
                foreach (var p in response.Results)
                {
                    System.Console.Out.WriteLine(p.BestName);
                }
            }
        }
Exemplo n.º 30
0
        public void PersonQueryReturnsCorrectDatabasePrefixForGivenType()
        {
            //Arrange
            PersonQuery criteria = new PersonQuery();
            //Act
            var nResponse  = criteria.getDatabasePrefix("FIRST_NAME");
            var siReponse  = criteria.getDatabasePrefix("TPCE_STUDENT");
            var ecResponse = criteria.getDatabasePrefix("EVENT_ATTENDEES");

            //Assert
            Assert.AreEqual("n.", nResponse);
            Assert.AreEqual("si.", siReponse);
            Assert.AreEqual("ec.", ecResponse);
        }
            public override Response <IPerson> FindPeople(PersonQuery query)
            {
                if (this.ForceErrorResult)
                {
                    throw new FindException("Stubbed client always errors!");
                }

                var results = new List <IPerson>();

                if (!this.ForceEmptyResult)
                {
                    results.Add(_person);
                }
                return(new Response <IPerson>(this, results, GetDictionary(this), _emptyMessages));
            }
Exemplo n.º 32
0
        protected void SaveClick(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {

                var userId = ((Person)Session["CurrentUser"]).Id;
                var user = new PersonQuery().Get(userId);

                user.Password = NewPassword.Text;
                PersonEdit.Instance.Update(user);

                NewPassword.Text = "";
                ClientScript.RegisterStartupScript(GetType(), "msg", "<script language='javascript'>showMessage()</script>");
            }
        }
Exemplo n.º 33
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindList();

                var userCode = Request.QueryString["code"];
                if (userCode != null)
                {
                    var current = new PersonQuery().Get(int.Parse(userCode));
                    CurrentUser = current;
                    FillFields(current);
                    PersonTypes.Enabled = false;

                    InitByUser();
                }
            }
        }
Exemplo n.º 34
0
        protected void DoLoginClick(object sender, EventArgs e)
        {
            var user = new PersonQuery { IdNum = UserName.Text }.GetByIdNum();

            if (!user.Any())
            {
                UserValidator.IsValid = false;
                return;
            }

            var currUser = user.Single();
            if (currUser.Password != Password.Text)
            {
                PasswordValidator.IsValid = false;
            }
            else
            {
                Session["CurrentUser"] = currUser;
                Page.Response.Redirect("~/Main.aspx");
            }
        }
Exemplo n.º 35
0
        private void SendMessageFromTeacher(List<Person> recipients)
        {
            var garden = new KindergardenQuery {TeacherId = _messageSender.Id}.Get().First();

            switch (Who.SelectedValue)
            {
                case "ילד ספציפי":
                    {
                        var child = new PersonQuery().Get(int.Parse(Where.SelectedValue));

                        if (child != null)
                        {
                            recipients.Add(child);
                        }
                        break;
                    }
                case "כל ילדי הגן":
                    {

                        if (garden != null)
                        {
                            recipients.AddRange(garden.Children);
                        }
                        break;
                    }
                case "מפקחת":
                    {
                        var supervisor = new SupervisorQuery {City = garden.City}.GetByFilter().FirstOrDefault();

                        if (supervisor != null)
                            recipients.Add(supervisor);
                        break;
                    }
            }
        }
Exemplo n.º 36
0
        private void SendMessageFromSupervisor(List<Person> recipients)
        {
            var countyGardens =
                new KindergardenQuery {City = ((Supervisor) _messageSender).City}.GetByFilter().ToList();

            switch (Who.SelectedValue)
            {
                case "גננת":
                    var teacher = new PersonQuery().Get(int.Parse(Where.SelectedValue));

                    if (teacher != null)
                    {
                        recipients.Add(teacher);
                    }
                    break;
                case "גננות המחוז":

                    recipients.AddRange(countyGardens.Select(c => c.Teacher).ToList());
                    break;
                case "ילדי המחוז":
                    foreach (var kindergarden in countyGardens)
                    {
                        recipients.AddRange(kindergarden.Children);
                    }
                    break;
            }
        }
Exemplo n.º 37
0
        private bool AddNewUser()
        {
            var isUserExist = new PersonQuery { IdNum = Id.Text }.GetByFilter().Any();
            if (isUserExist)
            {
                IdValidator.IsValid = false;
                return false;
            }

            var selected = PersonTypes.SelectedValue;

            switch (selected)
            {
                case "1":
                    {
                        var entity = new Entities.Child
                                         {
                                             IdNum = Id.Text,
                                             FirstName = FirstName.Text,
                                             LastName = LastName.Text,
                                             BirthDay = DateTime.Parse(BirthDate.Text),
                                             PhoneNum = Phone.Text,
                                             Password = "******",
                                             Sensitivitieses = GetSensitivitieses()
                                         };

                        ChildEdit.Instance.Add(entity);
                        break;
                    }
                case "2":
                    {
                        var entity = new Entities.Teacher
                                         {
                                             IdNum = Id.Text,
                                             FirstName = FirstName.Text,
                                             LastName = LastName.Text,
                                             BirthDay = DateTime.Parse(BirthDate.Text),
                                             Substitute =
                                                 Teachers.SelectedValue != ""
                                                     ? new TeachersQuery().Get(int.Parse(Teachers.SelectedValue))
                                                     : null,
                                             PhoneNum = Phone.Text,
                                             Seniority = Sen.Text != "" ? int.Parse(Sen.Text) : 0,
                                             Password = "******"
                                         };
                        TeacherEdit.Instance.Add(entity);
                        break;
                    }

                case "3":
                    {
                        var city = Enum.Parse(typeof(Entities.Cities), Cities.SelectedIndex.ToString(), true);

                        var entity = new Entities.Supervisor
                                         {
                                             IdNum = Id.Text,
                                             FirstName = FirstName.Text,
                                             LastName = LastName.Text,
                                             BirthDay = DateTime.Parse(BirthDate.Text),
                                             PhoneNum = Phone.Text,
                                             Password = "******",
                                             City = (Entities.Cities)city
                                         };
                        SupervisorEdit.Instance.Add(entity);
                        break;
                    }
            }
            return true;
        }
Exemplo n.º 38
0
 public SpecificationQueryTest()
 {
     Specification = new PersonQuery();
 }