예제 #1
0
        public UploadResponseViewModel(UploadRequestViewModel model)
        {
            Id           = model.Id;
            AttachmentId = model.AttachmentId;

            if (model.Profile != null)
            {
                Profile = new ProfileResponseViewModel(model.Profile);
            }

            if (model.Attachment != null)
            {
                Attachment = new HttpFileBaseResponseViewModel(model.Attachment);
            }

            if (model.Attachments != null && model.Attachments.Count > 0)
            {
                Attachments = model.Attachments.Select(attachment => new HttpFileBaseResponseViewModel(attachment))
                              .ToList();
            }

            Ids = model.Ids;
            NonNullableQuality = model.NonNullableQuality;
            NullableQuality    = model.NullableQuality;
            Qualities          = model.Qualities;
        }
예제 #2
0
        public void Post([FromBody] UploadRequestViewModel model)
        {
            MemoryStream file = new MemoryStream();

            CopyStream(model.File.InputStream, file);
            var createPizza = new CreatePizza()
            {
                Name = model.Name, Ingredients = model.Ingredients, File = file.ToArray(), MIMEType = model.File.ContentType
            };

            _logger.Write(createPizza);
        }
        public IActionResult BasicUpload([FromBody] UploadRequestViewModel model)
        {
            if (model == null)
            {
                model = new UploadRequestViewModel();
                TryValidateModel(model);
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }


            return(Ok(new UploadResponseViewModel(model)));
        }
예제 #4
0
        public IHttpActionResult BasicUpload(UploadRequestViewModel model)
        {
            if (model == null)
            {
                model = new UploadRequestViewModel();
                Validate(model);
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }


            return(Ok(new UploadResponseViewModel(model)));
        }