public async Task <ActionResult> AddActionPlanFormData([FromForm] ActionPlanParams obj) { string token = Request.Headers["Authorization"]; var userID = Extensions.GetDecodeTokenByProperty(token, "nameid").ToInt(); obj.OwnerID = userID; IFormFile file = Request.Form.Files["UploadedFile"]; if (file != null) { if (!Directory.Exists(_environment.WebRootPath + "\\ExcelFolder\\")) { Directory.CreateDirectory(_environment.WebRootPath + "\\ExcelFolder\\"); } using (FileStream fileStream = System.IO.File.Create(_environment.WebRootPath + "\\ExcelFolder\\" + file.FileName)) { file.CopyTo(fileStream); fileStream.Flush(); } obj.FileName = file.FileName; } else { obj.FileName = null; } var data = await _actionPlanService.AddActionPlanFormData(obj); await _hubContext.Clients.All.SendAsync("ReceiveMessage", "user", "message"); return(Ok(new { status = data.Status, isSendmail = true, message = data.Message })); }