public async Task <IActionResult> Create(AuditType_D_Dto auditTypeDto) { var username = User.FindFirst(ClaimTypes.Name).Value; auditTypeDto.Updated_By = username; if (await _auditTypeDService.Add(auditTypeDto)) { return(CreatedAtRoute("GetAuditTypeDs", new { })); } throw new Exception("Creating the AuditType failed on save"); }
public async Task <IActionResult> Create([FromForm] AuditType_D_Dto auditTypeDto) { IFormFile filevideo = Request.Form.Files["filevideo"]; auditTypeDto.Audit_Type_ID = Request.Form["audit_Type_ID"]; auditTypeDto.Audit_Item_ID = Request.Form["audit_Item_ID"]; auditTypeDto.Audit_Type3_ZW = Request.Form["audit_Type3_ZW"]; auditTypeDto.Audit_Type3_EN = Request.Form["audit_Type3_EN"]; auditTypeDto.Audit_Type3_LL = Request.Form["audit_Type3_LL"]; auditTypeDto.Audit_Item_EN = Request.Form["audit_Item_EN"]; auditTypeDto.Audit_Item_LL = Request.Form["audit_Item_LL"]; auditTypeDto.Audit_Item_ZW = Request.Form["audit_Item_ZW"]; auditTypeDto.Rating_0 = Request.Form["rating_0"].ToInt(); auditTypeDto.Rating_1 = Request.Form["rating_1"].ToInt(); auditTypeDto.Rating_2 = Request.Form["rating_2"].ToInt(); // auditTypeDto.Version = Request.Form["version"].ToInt(); // auditTypeDto.Visible = Request.Form["visible"].ToBool(); //auditTypeDto.Movie_Name = Request.Form["movie_Name"]; string name = _auditTypeDService.GetNameVideoByID(auditTypeDto.Audit_Type_ID); string folder = _webHostEnvironment.WebRootPath + "\\uploaded\\video"; var file = filevideo; if (filevideo != null) { var filenameB4 = ContentDispositionHeaderValue .Parse(file.ContentDisposition) .FileName .Trim('"'); filenameB4 = name + "_" + auditTypeDto.Audit_Item_ID + "_" + Path.GetExtension(filenameB4); string filePathB4 = Path.Combine(folder, filenameB4); using (FileStream fs = System.IO.File.Create(filePathB4)) { filevideo.CopyTo(fs); fs.Flush(); } auditTypeDto.Movie_Name = filenameB4; } var username = User.FindFirst(ClaimTypes.NameIdentifier).Value; auditTypeDto.Updated_By = username; // auditTypeDto.Updated_Time = DateTime.Now; if (await _auditTypeDService.Add(auditTypeDto)) { return(CreatedAtRoute("GetAuditTypeDs", new { })); } throw new Exception("Creating the AuditType failed on save"); }