public async Task <IHttpActionResult> Post()
        {
            if (!Request.Content.IsMimeMultipartContent())
            {
                return(BadRequest());
            }
            var provider = new CustomMultipartFileStreamProvider();
            await Request.Content.ReadAsMultipartAsync(provider);

            var reservation = provider.Reservation;

            Validate <ReservationDTO>(reservation);
            if (ModelState.IsValid && reservation != null)
            {
                var identity = (ClaimsIdentity)User.Identity;
                var userId   = identity.Claims.FirstOrDefault(s => s.Type == "id").Value;
                var result   = await _reservationService.Create(reservation, userId, _rootPath);

                if (result.Succedeed)
                {
                    return(Ok());
                }
                else
                {
                    return(BadRequest(result.Message));
                }
            }
            else
            {
                return(BadRequest(ModelState.Values.FirstOrDefault().Errors.FirstOrDefault().ErrorMessage));
            }
        }
        public async Task <IHttpActionResult> Post()
        {
            if (!Request.Content.IsMimeMultipartContent())
            {
                return(BadRequest());
            }
            var provider = new CustomMultipartFileStreamProvider();
            // путь к папке на сервере
            string root = System.Web.HttpContext.Current.Server.MapPath("~/App_Data/");
            await Request.Content.ReadAsMultipartAsync(provider);


            return(Ok(provider.Reservation));
        }
        public async Task <string> UploadPartial()
        {
            //assemble parameters
            var streamProvider = new CustomMultipartFileStreamProvider();
            await Request.Content.ReadAsMultipartAsync(streamProvider);

            string md5OfResource    = streamProvider.FormData["md5OfResource"];
            string uploadIdentifier = streamProvider.FormData["uploadIdentifier"];
            int    partNumber       = int.Parse(streamProvider.FormData["partNumber"]);
            int    numberOfParts    = int.Parse(streamProvider.FormData["numberOfParts"]);

            string id = String.Empty;
            HttpResponseMessage response = new HttpResponseMessage();
            var httpRequest = HttpContext.Current.Request;

            //DigitalResource resource = null;
            //if (albumID != null)
            foreach (KeyValuePair <string, Stream> file in streamProvider.FileStreams)
            {
                string fileName = file.Key;
                Stream stream   = file.Value;
                //System.Web.HttpFileCollection files = System.Web.HttpContext.Current.Request.Files;
                Repository.ResourceRepository repository    = new Repository.ResourceRepository();
                ReferenceRepository           refRepository = new ReferenceRepository();
                UserRepository ur          = new UserRepository();
                string         currentUser = User.Identity.Name;
                User           user        = ur.Get(currentUser);
                //Album album = repository.GetAlbums(x => x.Name == albumID).FirstOrDefault();

                //string name = file.FileName;

                id = await repository.UploadPartial(user, md5OfResource, uploadIdentifier, stream, partNumber, numberOfParts);
            }

            return(id);
        }