Esempio n. 1
0
 public ActionResult Delete(PersonCL.Person person)
 {
     Person.Models.PersonViewModel per = new Models.PersonViewModel()
     {
         Id = person.ID, Age = person.Age, FirstName = person.FirstName, LastName = person.LastName
     };
     return(View(per));
 }
Esempio n. 2
0
        public IHttpActionResult PostNewPerson(Models.PersonViewModel pPerson)
        {
            if (ModelState.IsValid)
            {
                using (StreamWriter sw = File.AppendText(HostingEnvironment.MapPath("~/InputFiles/Pipe.txt")))
                {
                    sw.WriteLine(pPerson.LastName + "|" + pPerson.FirstName + "|" + pPerson.PersonGender + "|" + pPerson.FavoriteColor + "|" + pPerson.DateOfBirth.ToShortDateString());
                }

                return(Ok());
            }
            else
            {
                return(BadRequest());
            }
        }
Esempio n. 3
0
        public ActionResult AddPerson(Models.PersonViewModel pPerson)
        {
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("http://localhost:62143/records");

                var postTask = client.PostAsJsonAsync <Models.PersonViewModel>("records", pPerson);
                postTask.Wait();

                var result = postTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    return(RedirectToAction("Index"));
                }
            }

            ModelState.AddModelError(string.Empty, "Server Error. Please contact administrator.");

            return(View(pPerson));
        }
Esempio n. 4
0
 public ActionResult Contact()
 {
     ViewBag.Message = "Your contact page.";
     Models.PersonViewModel p = new Models.PersonViewModel();
     return(View(p));
 }
 public ActionResult Index()
 {
     var model = new Models.PersonViewModel() { Name = "Anonymous", Deposit = 50 };
     return View(model);
 }
Esempio n. 6
0
 public ActionResult Delete(PersonCL.Person person)
 {
     Person.Models.PersonViewModel per = new Models.PersonViewModel() { Id = person.ID, Age = person.Age, FirstName = person.FirstName, LastName = person.LastName };
     return View(per);
 }