Beispiel #1
0
        public ActionResult Create(PetAnimalCreateViewModel model)
        {
            if (ModelState.IsValid)
            {
                var animal = new PetMatch.Web.PetAnimal()
                {
                    Name = model.Name,
                    Visible = model.Visible,
                    DateCreated = DateTime.UtcNow,
                    // TODO: Fix this hack
                    CreatedBy = "dcruz" //User.Identity.Name
                };

                if (animal.IsValid)
                {
                    animal.AcceptChanges();
                    return RedirectToAction("Index", "PetAnimal");
                }

                ModelState.AddModelError("NotIsValid", animal.ValidationMessage);
            }

            return View("Index", new PetAnimalIndexViewModel { CreateViewModel = model });
            //return PartialView("CreatePartial", model);
        }
Beispiel #2
0
 public ActionResult Edit(PetAnimalCreateViewModel model)
 {
     return View("PetAnimal", new PetAnimalIndexViewModel { CreateViewModel = model });
 }