public async Task <IActionResult> Post([FromForm] JournalViewModel model) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (_journalService.IfJournalAlreadyExist(model.Title)) { throw new DuplicateNameException("Duplicate Entry"); } var fileUploadPath = Path.Combine(_hostingEnvironment.WebRootPath, "upload/thesisFile"); model.ThesisFileUrl = await _uploadService.FileUploader(model.ThesisFile, fileUploadPath); await _journalService.Add(model); return(Ok(model)); } catch (Exception e) { return(BadRequest("Cannot connect to the server at the moment, try again")); } }