public ActionResult AddPeople(People person)
        {
            PeopleService peopleService = new PeopleService();

            peopleService.AddPeople(person);
            return(RedirectToAction("ListPeople"));
        }
        public async Task <IActionResult> AddPeople(model.People people)
        {
            bool add = await peopleService.AddPeople(people);

            if (add)
            {
                return(Accepted());
            }
            else
            {
                return(BadRequest(""));
            }
        }
        public ActionResult Create(People people)
        {
            try
            {
                people.CreatedDate        = DateTime.Now;
                people.UpdateDate         = DateTime.Now;
                people.LastLockedDateTime = DateTime.Now;

                _peopleService.AddPeople(people);

                return(RedirectToAction("Index"));
            }
            catch (Exception)
            {
                return(View());
            }
        }
Beispiel #4
0
        protected void CreateOrUpdateMethod(object sender, EventArgs e)
        {
            var serv = new PeopleService();

            if (string.IsNullOrEmpty(IdBox.Text))
            {
                serv.AddPeople(NameBox.Text, Convert.ToInt32(WeightBox.Text), Convert.ToInt32(HeightBox.Text));
            }
            else
            {
                serv.SetPeople(Convert.ToInt32(IdBox.Text), NameBox.Text, Convert.ToInt32(WeightBox.Text), Convert.ToInt32(HeightBox.Text));
            }

            NameBox.Text   = string.Empty;
            WeightBox.Text = string.Empty;
            HeightBox.Text = string.Empty;
            IdBox.Text     = string.Empty;

            //Refresh data
            PeopleTable.DataSource = serv.GetPeoples();
            PeopleTable.DataBind();
        }
Beispiel #5
0
        public void AddPeopleByNullTest()
        {
            var result = peopleserv.AddPeople(null);

            Assert.AreEqual(result.ErrorMessage, "People not be null");
        }
Beispiel #6
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            var personID = Request.QueryString["ID"];

            if ((Page.IsValid) && (personID == null)) //user can disable the js control
            {
                Contoso.Models.People people = new Contoso.Models.People();
                people.LastName              = txtLastName.Text;
                people.FirstName             = txtFirstName.Text;
                people.MiddleName            = txtMiddleName.Text;
                people.Age                   = Convert.ToInt32(txtAge.Text);
                people.Email                 = txtEmail.Text;
                people.Phone                 = txtPhone.Text;
                people.AddressLine1          = txtAddress1.Text;
                people.AddressLine2          = txtAddress2.Text;
                people.UnitOrApartmentNumber = Convert.ToInt32(txtUnitOrApartmentNumber.Text);
                people.City                  = txtCity.Text;
                people.State                 = ddlStates.SelectedValue;
                people.ZipCode               = txtZipCode.Text;
                people.CreatedDate           = Convert.ToDateTime(txtCreatedDate.Text);
                people.CreatedBy             = txtCreatedBy.Text;
                people.UpdatedDate           = Convert.ToDateTime(txtUpdatedDate.Text);
                people.UpdatedBy             = txtUpdatedBy.Text;
                people.Password              = txtPassword.Text;
                people.Salt                  = txtSalt.Text;
                if (ddlIsLocked.SelectedValue == "Yes")
                {
                    people.IsLocked = true;
                }
                if (ddlIsLocked.SelectedValue == "No")
                {
                    people.IsLocked = false;
                }
                people.LastLockedDateTime = Convert.ToDateTime(txtLastLockedDateTime.Text);
                people.FailedAttempts     = Convert.ToInt32(txtFailedAttempts.Text);
                PeopleService peopleService = new PeopleService();
                peopleService.AddPeople(people);
            }
            if ((Page.IsValid) && (personID != null)) //user can disable the js control
            {
                Contoso.Models.People people = new Contoso.Models.People();
                people.ID                    = Convert.ToInt32(personID);
                people.LastName              = txtLastName.Text;
                people.FirstName             = txtFirstName.Text;
                people.MiddleName            = txtMiddleName.Text;
                people.Age                   = Convert.ToInt32(txtAge.Text);
                people.Email                 = txtEmail.Text;
                people.Phone                 = txtPhone.Text;
                people.AddressLine1          = txtAddress1.Text;
                people.AddressLine2          = txtAddress2.Text;
                people.UnitOrApartmentNumber = Convert.ToInt32(txtUnitOrApartmentNumber.Text);
                people.City                  = txtCity.Text;
                people.State                 = ddlStates.SelectedValue;
                people.ZipCode               = txtZipCode.Text;
                people.CreatedDate           = Convert.ToDateTime(txtCreatedDate.Text);
                people.CreatedBy             = txtCreatedBy.Text;
                people.UpdatedDate           = Convert.ToDateTime(txtUpdatedDate.Text);
                people.UpdatedBy             = txtUpdatedBy.Text;
                people.Password              = txtPassword.Text;
                people.Salt                  = txtSalt.Text;
                if (ddlIsLocked.SelectedValue == "Yes")
                {
                    people.IsLocked = true;
                }
                if (ddlIsLocked.SelectedValue == "No")
                {
                    people.IsLocked = false;
                }
                people.LastLockedDateTime = Convert.ToDateTime(txtLastLockedDateTime.Text);
                people.FailedAttempts     = Convert.ToInt32(txtFailedAttempts.Text);
                PeopleService peopleService = new PeopleService();
                peopleService.UpdatePeople(people);
            }
        }