public void AddWorkWithSingleFile(CreateWorkDto createWork) { var work = new Work { Title = createWork.Title, Description = createWork.Description, workStatus = WorkStatus.Pendding, DeveloperId = createWork.DeveloperId, SprintTaskId = createWork.SprintTaskId, }; db.Works.Add(work); db.SaveChanges(); Stream st = createWork.TheFile.OpenReadStream(); // strem file inside it using (BinaryReader br = new BinaryReader(st))//binary reader stream inside it { var byteFile = br.ReadBytes((int)st.Length); var file = new Models.File(); file.FileName = createWork.TheFile.FileName; file.FileExtension = createWork.TheFile.ContentType; file.FileBytes = byteFile; file.WorkId = work.Id; db.Files.Add(file); db.SaveChanges(); } db.SaveChanges(); }
public void CreateWork(CreateWorkDto createWorkDto) { var work = new Work() { Title = createWorkDto.Title, Description = createWorkDto.Description }; db.Add(work); db.SaveChanges(); }
public IActionResult InsertWork(CreateWorkDto workDto) { if (ModelState.IsValid) { workDto.TaskID = _taskId; workDto.DeveloperId = User.FindFirst(ClaimTypes.NameIdentifier).Value; workRepository.InsertWork(workDto); return(RedirectToAction("ShowTaskWorks", new { @taskId = _taskId })); } else { return(View("Create")); } }
public IActionResult CreateWork(CreateWorkDto createWorkDto) { if (ModelState.IsValid) { developerRepository.AddWork(createWorkDto); return(RedirectToAction("ShowProjects")); } else { ViewBag.SprintTaskId = createWorkDto.SprintTaskId; ViewBag.userId = User.FindFirst(ClaimTypes.NameIdentifier).Value; return(View("CreateWork")); } }
public void AddWork(CreateWorkDto createWorkDto) { try { var work = new Work() { DeveloperId = createWorkDto.DeveloperId, Title = createWorkDto.Title, Description = createWorkDto.Description, SprintTaskId = createWorkDto.SprintTaskId, workStatus = WorkStatus.Pendding, }; Db.Works.Add(work); Db.SaveChanges(); if (createWorkDto.TheFile != null) { foreach (var Fl in createWorkDto.TheFile) { var file = new Models.File() { WorkId = work.Id }; Stream st = Fl.OpenReadStream(); using (BinaryReader br = new BinaryReader(st)) { var byteFile = br.ReadBytes((int)st.Length); file.FileName = Fl.FileName; file.FileType = Fl.ContentType; file.FileBytes = byteFile; } Db.Files.Add(file); Db.SaveChanges(); } } } catch (Exception) { throw; } }
public void InsertWork(CreateWorkDto workDto) { Work work = new Work() { DeveloperId = workDto.DeveloperId, Title = workDto.Title, Description = workDto.Description, Status = Status.PendingApproval, TaskId = workDto.TaskID }; Stream stream = workDto.workFile.OpenReadStream(); using (BinaryReader br = new BinaryReader(stream)) { var byteFile = br.ReadBytes((int)stream.Length); work.FileName = workDto.workFile.FileName; work.FileType = workDto.workFile.ContentType; work.workFile = byteFile; } context.Works.Add(work); context.SaveChanges(); }
public void AddWork(CreateWorkDto createWork) { throw new NotImplementedException(); }
public IActionResult CreateWork(CreateWorkDto createWork) { developerRepository.AddWorkWithSingleFile(createWork); return(Redirect("ShowProjects")); }
public IActionResult Create(CreateWorkDto createWorkDto) { workRepository.CreateWork(createWorkDto); return(Redirect("GetAllWorks")); }