public JsonResult BallotsForLocation(int id)
        {
            var peopleModel = new PeopleModel();

            return(new
            {
                Ballots = peopleModel.BallotSources(id),
                Deselected = peopleModel.Deselected()
            }.AsJsonResult());
        }
        public ActionResult Details()
        {
            PeopleModel peopleModel = new PeopleModel();

            peopleModel.MyID         = _people.MyID();
            peopleModel.MyName       = _people.MyName();
            peopleModel.MyOccuptaion = _people.MyOccuptaion();

            return(View(peopleModel));
        }
Exemple #3
0
        public void GetsCorrectMaleOwnedCats()
        {
            //Arrange
            var classUnderTest = new PeopleModel(_peopleList);

            //Act
            var maleOwnedCats = classUnderTest.GetPetsByOwnerGenderAndPetType(Gender.Male, PetType.Cat);

            //Assert
            Assert.AreEqual(1, maleOwnedCats.Count);
        }
Exemple #4
0
        private static void UpdateContact(SqlCrud sql)
        {
            PeopleModel contact = new PeopleModel
            {
                Id        = 1,
                FirstName = "Doina",
                LastName  = "Stef"
            };

            sql.UpdateContactName(contact);
        }
        public IActionResult Create([FromBody] PeopleModel person)
        {
            if (person == null)
            {
                return(BadRequest());
            }
            _ctx.Add(person);
            _ctx.SaveChanges();

            return(Created("api/people", person));
        }
        public ActionResult Edit(int id)
        {
            PeopleModel m = new PeopleModel {
                IdPersona = id
            };

            if (id != 0)
            {
                m.GetCustomSinglePeople();
            }
            return(PartialView("_PeopleEdit", m));
        }
 public override Response Delete()
 {
     try
     {
         PeopleModel.Delete(_personName);
     }
     catch (ArgumentException)
     {
         return(new Response(403));
     }
     return(new Response(204));
 }
        // GET: People
        public ActionResult Index()
        {
            SearchModel m = new SearchModel
            {
                Action     = "Search",
                Controller = "People",
                Model      = PeopleModel.GetCustomSearchPeople(string.Empty, 20),
                Persona    = new CustomPeopleModel()
            };

            return(View(m));
        }
Exemple #9
0
        public void TestSql()
        {
            PeopleModel p1 = DbEntry.ExecuteList <PeopleModel>("Select [Id],[Name] From [People] Where [Id] = 2")[0];

            Assert.AreEqual("Jerry", p1.Name);
            p1 = DbEntry.ExecuteList <PeopleModel>(new SqlStatement("Select [Name],[Id] From [People] Where [Id] = 1"))[0];
            Assert.AreEqual("Tom", p1.Name);
            p1 = PeopleModel.FindBySql("Select [Id],[Name] From [People] Where [Id] = 2")[0];
            Assert.AreEqual("Jerry", p1.Name);
            p1 = PeopleModel.FindBySql(new SqlStatement("Select [Name],[Id] From [People] Where [Id] = 3"))[0];
            Assert.AreEqual("Mike", p1.Name);
        }
Exemple #10
0
        public async Task <ActionResult> People(PeopleModel model)
        {
            var fileInfo = new FileInformation();

            _repository.SavePeople(model.Upload.InputStream, model.Upload.FileName, out fileInfo);

            model.People = _repository.GetPeople().Take(10000).Select(p => new PersonModel()
            {
                Id = p.Id, FirstName = p.FirstName, LastName = p.LastName, MiddleName = p.MiddleName
            }).ToList();
            return(View(model));
        }
        // Should only be called with a list of people that does not already exist!!!
        public static void Createpeople(string firstname, string lastname)
        {
            PeopleModel data = new PeopleModel
            {
                FirstName = firstname,
                LastName  = lastname
            };

            string sql = @"INSERT INTO people (FirstName, LastName) VALUES (@FirstName, @LastName)";

            SqlDataAccess.SaveData(sql, data);
        }
Exemple #12
0
        public async Task <PeopleModel> GetResidentsPerPlanetAsync(string url)
        {
            var response          = new PeopleModel();
            var planetGetResponse = await _peopleRequestHelper.GetAsync(url);

            if (planetGetResponse != null)
            {
                response = planetGetResponse;
            }

            return(response);
        }
 public ActionResult Save(CustomPeopleModel m)
 {
     if (ModelState.IsValid)
     {
         PeopleModel.SaveNew(m);
         return(RedirectToAction("Index"));
     }
     else
     {
         return(View("_PeopleEdit", m));
     }
 }
        public async Task <IActionResult> PeopleObj()
        {
            var response = await _peopleObjClient.GetPeopleInfo();

            var model = new PeopleModel();

            model.name = response.name;



            return(View(model));
        }
        public override Response Post(string body)
        {
            if (PeopleModel.People.Any(p => p.Name == body) || body == "")
            {
                return(new Response(202));
            }
            PeopleModel.Add(body);
            var response = new Response(201, body);

            response.Headers["Location"] = $"http://localhost:8080/people/{body}";
            return(response);
        }
Exemple #16
0
        public IActionResult Add(PeopleModel record)
        {
            if (ModelState.IsValid)
            {
                var source = new SourceManager();
                source.Add(record);

                return(RedirectToAction("Index"));
            }

            return(View(record));
        }
Exemple #17
0
 public ActionResult CreatePeople(PeopleModel member)
 {
     if (String.IsNullOrEmpty(member.Name) || member.Phone == 0 || String.IsNullOrEmpty(member.City))
     {
         return(View());
     }
     else
     {
         member.Id = peopleList.Count + 1;
         peopleList.Add(member);
         return(RedirectToAction("PeopleView"));
     }
 }
Exemple #18
0
        public ActionResult ToModelValid(PeopleModel people)
        {
            var valid = people.GetModelValid();

            if (valid.IsValid)
            {
                return(Json("验证成功"));
            }
            else
            {
                return(Json(valid.ErrorMessage));
            }
        }
Exemple #19
0
        public ActionResult Index(int?page)
        {
            var profiles = Repository.GetUserProfiles(Security.CurrentUserId, page ?? 0);
            var model    = new PeopleModel {
                Profiles = profiles
            };

            if (IsAjaxRequest())
            {
                return(Json(model.Profiles, JsonRequestBehavior.AllowGet));
            }

            return(View(model));
        }
Exemple #20
0
 public ActionResult EditPeople(PeopleModel member)
 {
     if (String.IsNullOrEmpty(member.Name) || member.Phone == 0 || String.IsNullOrEmpty(member.City))
     {
         return(View());
     }
     else
     {
         var people = peopleList.Where(s => s.Id == member.Id).FirstOrDefault();
         peopleList.Remove(people);
         peopleList.Add(member);
         return(RedirectToAction("PeopleView"));
     }
 }
Exemple #21
0
        public static int CreatePaople(string firstName, string lastName, DateTime birthDate)
        {
            PeopleModel data = new PeopleModel
            {
                FirstName = firstName,
                LastName  = lastName,
                BirthDate = birthDate
            };

            string sql = @"INSERT INTO People (FirstName, LastName, BirthDate)
                                        VALUES (@FirstName, @LastName, @BirthDate)";

            return(SQLDataAccess.SaveData(sql, data));
        }
        public override Response Put(string body)
        {
            var person = PeopleModel.Find(_personName);

            if (person == null)
            {
                return(new Response(404));
            }
            person.Name = body;
            var response = new Response(301);

            response.Headers["Location"] = $"http://localhost:8080/people/{body}";
            return(response);
        }
Exemple #23
0
 public List <PeopleModel> PeopleCreate(string Name, string Patronymic, string Surname, string Comment)
 {
     using (PeopleContext db = new PeopleContext())
     {
         PeopleModel NewPeople = new PeopleModel();
         NewPeople.Comment    = Comment;
         NewPeople.Surname    = Surname;
         NewPeople.Patronymic = Patronymic;
         NewPeople.Name       = Name;
         db.Peoples.Add(NewPeople);
         db.SaveChanges();
         var peoples = db.Peoples.ToList();
         return(peoples);
     }
 }
        /**
         * Transforma o model em List DTO
         */
        public static PeopleListDto ToListDto(this PeopleModel value)
        {
            if (value == null)
            {
                return(null);
            }

            return(new PeopleListDto()
            {
                Id = value.Id,
                Document = value.Document,
                Email = value.Email,
                Name = value.Name
            });
        }
        public PeopleModel MapToModel(PeopleGetResponseDto request)
        {
            var response = new PeopleModel
            {
                Name      = request.name,
                Height    = request.height,
                Weight    = request.mass,
                HairColor = request.hair_color,
                SkinColor = request.skin_color,
                EyeColor  = request.eye_color,
                Gender    = request.gender
            };

            return(response);
        }
        public PrivateMessagingPresenter(IPrivateMessageListProducer producer)
        {
            PageNavigator = new PageNavigatorAdapter()
            {
                IconSource = StaticResources.Icons.MessageWhite
            };
            PullToRefresh = new ListViewPullToRefreshViewModel();
            this.producer = producer;

            //todo: !
            Account   = new PeopleModel();
            MessageTo = new PeopleModel();

            producer.Receive(this);
        }
        public ActionResult SavePeople(PeopleModel model)
        {
            var context = GlobalHost.ConnectionManager.GetHubContext <PeopleHub>();

            PeopleModel person = new PeopleModel
            {
                Id    = model.Id,
                Title = model.Title,
                Name  = model.Name
            };

            context.Clients.All.setPerson(person.Id, person.Title, person.Name, false);

            return(this.RedirectToAction("Index", "Home"));
        }
Exemple #28
0
        private async Task ValidateUpsert(PeopleModel model)
        {
            if (string.IsNullOrEmpty(model.Name))
            {
                throw new ValidationException("Nome é obrigatório.");
            }

            if (string.IsNullOrEmpty(model.Document))
            {
                throw new ValidationException("Documento é obrigatório.");
            }

            if (string.IsNullOrEmpty(model.Email))
            {
                throw new ValidationException("E-mail é obrigatório.");
            }

            try
            {
                MailAddress m = new MailAddress(model.Email);
            }
            catch (FormatException)
            {
                throw new ValidationException("E-mail não é um endereço válido.");
            }

            // somente numeros
            Regex regex = new Regex(@"^\d*$");

            if (!regex.IsMatch(model.Document))
            {
                throw new ValidationException("Documento é inválido.");
            }

            var sameEmail = await _repository.GetByEmail(model.Id, model.Email);

            if (sameEmail != null)
            {
                throw new ValidationException("E-mail já está sendo utilizado por outra pessoa.");
            }

            var sameDocument = await _repository.GetByDocument(model.Id, model.Document);

            if (sameDocument != null)
            {
                throw new ValidationException("Documento já está sendo utilizado por outra pessoa.");
            }
        }
Exemple #29
0
        private List <string> ValidatePerson(PeopleModel person)
        {
            var errors = new List <string>();

            if (String.IsNullOrWhiteSpace(person.FirstName))
            {
                errors.Add("First Name is required");
            }
            if (String.IsNullOrWhiteSpace(person.LastName))
            {
                errors.Add("Last Name is required");
            }


            return(errors);
        }
        public ActionResult Search(SearchModel m)
        {
            IEnumerable <CustomPeopleModel> r = PeopleModel.GetCustomSearchPeople(m.Buscar.Trim());

            if (r != null && r.Count() == 1)
            {
                return(PartialView("_PeopleEdit", new PeopleModel {
                    IdPersona = r.First().IdPersona, Persona = r.First()
                }));
            }
            else if (r != null && r.Count() > 1)
            {
                return(PartialView("_PeopleList", r));
            }
            return(PartialView("_PeopleList", new List <CustomPeopleModel>()));
        }