Ejemplo n.º 1
0
        public ActionResult Create(SheepInput input)
        {
            // Validate the model being submitted
            if (!ModelState.IsValid)
            {
                // If the incoming request is an Ajax Request
                // then we just return a partial view (snippet) of HTML
                // instead of the full page
                if (Request.IsAjaxRequest())
                    return PartialView("_AddSheep", input);

                return View("AddSheep",input);
            }

            _sheepService.AddNewSheep(_mapper.Map<Sheep>(input));

            if (Request.IsAjaxRequest())
            {

                return PartialView("_SheepAddedConfirmation", input);
            }

            // A standard (non-Ajax) HTTP Post came in
            // set TempData and redirect the user back to the Home page
            TempData["Message"] = string.Format("The provided info has been saved.");
            return RedirectToAction("Index");
        }
Ejemplo n.º 2
0
        public ActionResult Create()
        {
            var viewModel = new SheepInput();
            viewModel.StatusList = _statusService.GetStatuses().ToSelectList("Id", "Description", "-1");
            if (Request.IsAjaxRequest())
            {
                return PartialView("_AddSheep", viewModel);
            }

            return View("AddSheep", viewModel);
        }