public async Task <ActionResult> Post([Bind(Include = "CompanyID,Title,Profession,Salary,SalaryRate,IsOpen,IsInvitationOnly,Location,ApplicationDeadlineDate,Description")] Job job, HttpPostedFileBase file) { if (ModelState.IsValid) { if (file != null && file.ContentLength > 0) { var fileName = Path.GetFileName(file.FileName); var extensions = fileName.Split('.'); var extension = extensions[extensions.Length - 1].ToLower(); if (extension.ToLower().Equals("docx")) { MemoryStream ms = new MemoryStream(); file.InputStream.CopyTo(ms); JobDescription JD = new JobDescription { DocumentName = fileName, DocumentType = DocumentType.docx, Document = ms.ToArray() }; job.JobDescriptionDocument = JD; } else { ViewBag.Message = "Select a valid file with 'docx' extension."; return(View(job)); } } await bll.AddJob(job); return(RedirectToAction("Index")); } return(View(job)); }
public async Task <IHttpActionResult> PostJob(Job job) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } await jobBLL.AddJob(job); return(CreatedAtRoute("DefaultApi", new { id = job.ID }, job)); }