Пример #1
0
        public IHttpActionResult Post(PhotoAlbumBindingModel albumBindingModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            PhotoAlbum photoAlbum = Mapper.Map <PhotoAlbumBindingModel, PhotoAlbum>(albumBindingModel);

            var userId = User.Identity.GetUserId();

            if (userId == null)
            {
                return(BadRequest("User Not Found"));
            }

            var user = _userService.GetById(userId);

            photoAlbum.User = user;

            _photoAlbumService.Add(photoAlbum);

            var photoAlbumViewModel = Mapper.Map <PhotoAlbum, PhotoAlbumWithImagesViewModel>(photoAlbum);

            return(Ok(photoAlbumViewModel));
        }