public ActionResult Create(CreateAdoptionFormViewModel model, int id) { if (model != null && ModelState.IsValid) { model.AnimalsDescription = this.sanitizeService.Sanitize(model.AnimalsDescription); model.ExpirienceWithAnimals = this.sanitizeService.Sanitize(model.ExpirienceWithAnimals); model.KidsDescription = this.sanitizeService.Sanitize(model.KidsDescription); model.Address = this.sanitizeService.Sanitize(model.Address); model.AttitudeAboutCastration = this.sanitizeService.Sanitize(model.AttitudeAboutCastration); var newAdoptionForm = AutoMapper.Mapper.Map <AdoptionForm>(model); newAdoptionForm.AnimalId = id; newAdoptionForm.Animal = animals.GetById(id).FirstOrDefault(); newAdoptionForm.UserId = this.User.Identity.GetUserId(); newAdoptionForm.User = adopters.GetById(newAdoptionForm.UserId).FirstOrDefault(); this.adoptionForms.AddNew(newAdoptionForm); return(this.RedirectToAction("Index", "Home", new { area = "" })); } else { return(this.View(model)); } }
public async Task <AnimalResource> Get(int id) { var animal = await _animalService.GetById(id); var resource = _mapper.Map <Animal, AnimalResource>(animal); return(resource); }
public async Task <IActionResult> Get(int id) { var animal = await _animalService.GetById(id); if (animal == null) { return(NotFound()); } return(Ok(animal)); }
public ActionResult Paging(int id, int?page) { var animal = animals.GetById(id).FirstOrDefault(); var comments = animal.Comments; int pageNumber = (page ?? 1); IEnumerable <CreateCommentViewModel> result = AutoMapper.Mapper.Map <IEnumerable <CreateCommentViewModel> >(comments); return(this.PartialView("_PagingComments", result.ToPagedList(pageNumber, 2))); }
public IActionResult Get(string id) { try { var animal = AnimalMapper.StoA(_animalService.GetById(new Guid(id))); return(Ok(animal)); } catch { return(BadRequest()); } }
public ActionResult <AnimalDto> GetAnimal(long id) { try { var animal = _animalService.GetById(id); return(Ok(animal)); } catch (Exception ex) { //log error return(NotFound(ex)); } }
public ActionResult Details(int id) { var animal = animals .GetById(id) .ProjectTo <AnimalDetailView>() .FirstOrDefault(); if (animal == null) { return(new HttpStatusCodeResult(HttpStatusCode.NotFound, "Not Found")); } return(View(animal)); }
public IActionResult Detail(string id) { Animal animal = m_AnimalService.GetById(id); AnimalModel animalModel = new AnimalModel( ) { Id = animal.Id, NickName = animal.NickName, Age = animal.Age, Species = animal.Species }; ViewBag.Animal = animalModel; return(View( )); }
public async Task <IActionResult> GetById(int id) { return(Ok(await _animalService.GetById(id, User))); }