public ActionResult AddNewDog([Bind(Exclude = "Photo,DogOwnerID,DogID")] DogViewModel dogToBeCreated, HttpPostedFileBase uploadPhoto)
        {
            if (!ModelState.IsValid)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            else
            {
                string userId = User.Identity.GetUserId();

                if (dogService.CreateDog(dogToBeCreated, userId, uploadPhoto))
                {
                    return(Json(true));
                }
                else
                {
                    return(Json(false));
                }
            }
        }
示例#2
0
 public async Task <ActionResult <Dog> > Post(Dog dog) =>
 await _service.CreateDog(dog, GetUserId());