public async Task <IActionResult> UpdateFormDocument(long id, FormDictionaryDto model, [FromServices] IActionService <IUpdateFormDictionaryAction> service) { model.Id = id; 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}")); } service.RunBizAction(model); if (!service.Status.HasErrors) { return(new ObjectResult(new ResultResponseDto <String, long> { Key = HttpStatusCode.OK, Value = "FormDocument updated..", Subject = model.Id })); } var errors = service.Status.CopyErrorsToString(ModelState); return(new ObjectResult(new ResultResponseDto <String, long> { Key = HttpStatusCode.BadRequest, Value = errors, Subject = model.Id })); }
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 })); }