public async Task <ActionResult> Create([Bind(Include = "Id,Notes,PictureReference,ConstructionProjectId")] ProgressTrackingEntry progressTrackingEntry) { if (ModelState.IsValid) { if (Request.Files.Count > 0) { var file = Request.Files[0]; if (file != null && file.ContentLength > 0) { var fileName = Path.GetFileName(file.FileName); var mimeType = MimeMapping.GetMimeMapping(fileName); var filePath = await _filesStorageService.UploadFile(fileName, file.InputStream, mimeType); progressTrackingEntry.PictureReference = filePath; } } progressTrackingEntry.EntryDate = DateTime.Now; _db.ProgressTrackingEntries.Add(progressTrackingEntry); await _db.SaveChangesAsync(); await _serviceBusManager.Enqueue(new ResizePictureMessage { Id = progressTrackingEntry.Id, PictureReference = progressTrackingEntry.PictureReference }); return(RedirectToAction("Index")); } ViewBag.ConstructionProjectId = new SelectList(_db.ConstructionProjects, "Id", "Name", progressTrackingEntry.ConstructionProjectId); return(View(progressTrackingEntry)); }