public ActionResult Create([Bind("ixDocument,sDocument,ixDocumentMessageType,sVersion,sRevision,ixStatus")] DocumentsPost documents) { if (ModelState.IsValid) { documents.UserName = User.Identity.Name; _documentsService.Create(documents); return(RedirectToAction("Index")); } ViewBag.ixDocumentMessageType = new SelectList(_documentsService.selectDocumentMessageTypes().Select(x => new { x.ixDocumentMessageType, x.sDocumentMessageType }), "ixDocumentMessageType", "sDocumentMessageType"); ViewBag.ixStatus = new SelectList(_documentsService.selectStatuses().Select(x => new { x.ixStatus, x.sStatus }), "ixStatus", "sStatus"); return(View(documents)); }
public async Task <IActionResult> Create([FromForm] DocumentsCreateRequest request) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var documentId = await _documentsService.Create(request); if (documentId == 0) { return(BadRequest()); } var document = await _documentsService.GetById(documentId); return(CreatedAtAction(nameof(GetById), new { id = documentId }, document)); }