public async Task <IActionResult> GetFormDocument(long id) { var listService = new ListFormDictionaryService(_context); var desciplineList = await listService.GetformDictionary(id); return(new ObjectResult(desciplineList)); }
public async Task <IActionResult> CreateFormDocument([FromServices] IActionService <IPlaceFormDictionaryAction> service) { if (Request.HasFormContentType) { var sModel = Request.Form["DocParameters"]; var model = JsonConvert.DeserializeObject <FormDictionaryDto>(sModel); if (model == null) { service.Status.AddError("some data are invalied..", "Form Document"); } if (!Request.Form.Files.Any()) { service.Status.AddError("File Not Valid!!!", "Form Document"); } model.File = Request.Form.Files[0]; var formService = new ListFormDictionaryService(_context); if (await formService.HasDuplicatedCode(model.Code)) { service.Status.AddError("Entered code is taked from other form!!!", "Form Document"); } if (!service.Status.HasErrors) { if (model.File != null && model.File.Length > 0) { FormDocumentFileHelper docHelper = new FormDocumentFileHelper(); string filePath = await docHelper.SaveFormDocument(model.Code, model.File, _enviroment); model.FileName = Path.Combine(Path.Combine(filePath, $"{model.Code}")); } var formDic = service.RunBizAction <FormDictionary>(model); return(new ObjectResult(new ResultResponseDto <String, long> { Key = HttpStatusCode.OK, Value = "FormDocument created..", Subject = formDic.Id })); } } var errors = service.Status.CopyErrorsToString(ModelState); service.Status.CopyErrorsToString(ModelState); return(new ObjectResult(new ResultResponseDto <String, int> { Key = HttpStatusCode.BadRequest, Value = errors })); }