public IActionResult UploadForm(FormInputModel input, IFormFile picture) { if (picture.Length > 0) { var fileName = Path.GetFileName(picture.FileName); var filePath = Path.Combine(_env.ContentRootPath, "Uploads", fileName); using (var stream = new FileStream(filePath, FileMode.Create)) { picture.CopyTo(stream); } } // Get the connection string from the Azure portal //var storageAccount = CloudStorageAccount.Parse("connection string"); //var blobClient = storageAccount.CreateCloudBlobClient(); //var container = blobClient.GetContainerReference("my-container"); //container.CreateIfNotExistsAsync(); //var blockBlob = container.GetBlockBlobReference("my-blob"); //using (var stream = new MemoryStream()) //{ // picture.CopyTo(stream); // blockBlob.UploadFromStreamAsync(stream); //} // Now return var success = DateTime.Now.Second % 2; if (success > 0) { return(Json(CommandResponse.Ok.AddMessage("Operation completed successfully"))); } return(Json(CommandResponse.Fail.AddMessage("Couldn't complete the operation"))); }
public async Task <IActionResult> Post([FromBody] FormInputModel formInputModel) { await _dbContext.Forms.AddAsync(Form.Create(formInputModel.Name, formInputModel.Description)); await _dbContext.SaveChangesAsync(); return(NoContent()); }
public IActionResult AcceptForm(FormInputModel input) { if (!ModelState.IsValid) { return(this.Content("Not Ok!")); } return(this.Content("Ok!")); }
public ActionResult Form(FormInputModel input, HttpPostedFileBase picture) { // Do some work Thread.Sleep(2000); // Now return var success = DateTime.Now.Second % 2; if (success > 0) { return(Json(CommandResponse.Ok.AddMessage(Strings_UI.Generic_OperationSuccess))); } return(Json(CommandResponse.Fail.AddMessage(Strings_UI.Generic_OperationFailure))); }
protected override async Task OnInitializedAsync() { FormInputObj = new FormInputModel(); FormInputListObj = await InputList.GetFormInputListAsync(DateTime.Now); editContext = new EditContext(FormInputObj); selectlist.Add(new SelectListItem() { Text = "A", Value = true }); selectlist.Add(new SelectListItem() { Text = "B", Value = false }); }