public ActionResult Download(string guid) { if (guid.IsNullOrWhiteSpace()) { Response.StatusCode = (int)HttpStatusCode.NotFound; var errorResponse = new { Success = "false", Message = "file not found" }; return Json(errorResponse, JsonRequestBehavior.AllowGet); } try { var jobGuid = Guid.Parse(guid); var job = _fpmUploadRepository.GetJob(jobGuid); var fileExt = Path.GetExtension(job.Filename); var filePath = Path.Combine(AppConfig.UploadFolder, jobGuid + fileExt); var fileData = System.IO.File.ReadAllBytes(filePath); var contentType = MimeMapping.GetMimeMapping(filePath); var cd = new ContentDisposition { FileName = job.Filename, Inline = true }; Response.AppendHeader("Content-Disposition", cd.ToString()); return File(fileData, contentType); } catch (Exception ex) { return Redirect("/NotFound"); } }
public ActionResult ChangeStatus(string guid, int actionCode) { if (guid.IsNullOrWhiteSpace() || actionCode == null) { Response.StatusCode = (int)HttpStatusCode.NotFound; var errorResponse = new { Success = "false", Message = "guid or action code missing" }; return Json(errorResponse, JsonRequestBehavior.AllowGet); } var jobGuid = Guid.Parse(guid); var uploadJob = _fpmUploadRepository.GetJob(jobGuid); uploadJob.Status = (UploadJobStatus)actionCode; var isUpdated = _fpmUploadRepository.UpdateJob(uploadJob); var response = new { Success = isUpdated ? "true" : "false", Message = "" }; return Json(response, JsonRequestBehavior.AllowGet); }