public IActionResult UpdateEmployee(Employee employee, String id) { if (!employee.EmployeeName.Equals("Välj")) //något måste vara valt { Case tempCase = mymodel.ReturnOneCase(id); tempCase.Employee = employee.EmployeeName; mymodel.SaveCase(tempCase); } return(RedirectToAction("StartManager")); //redirect till StartManager }
public IActionResult UpdateDepartment(Department department, String id) { if (!department.DepartmentName.Equals("Välj")) //something must be chosen { Case tempCase = mymodel.ReturnOneCase(id); tempCase.Department = department.DepartmentName; mymodel.SaveCase(tempCase); } return(RedirectToAction("StartCoordinator")); //redirect to StartCoordinator }
// GET: /<controller>/ //Uppdaterar information om ett case som läggs in av Investigator. Kopplar också bilder/samples till caset samt laddar upp dem till DB public IActionResult UpdateCase(String events, String information, Status status, String id, IFormFile loadSample, IFormFile loadImage) { Case tempCase = mymodel.ReturnOneCase(id); try { var filePathSample = Path.Combine(environment.WebRootPath, "Samples", loadSample.FileName); ViewBag.Path = filePathSample; if (loadSample.Length > 0) { using (var stream = new FileStream(filePathSample, FileMode.Create)) { loadSample.CopyToAsync(stream); stream.Dispose(); } } Sample tempSample = new Sample(); tempSample.CaseID = tempCase.ID; tempSample.SampleName = loadSample.FileName; tempCase.Samples.Add(tempSample); } catch (Exception e) { } try { var filePathImage = Path.Combine(environment.WebRootPath, "Pictures", loadImage.FileName); ViewBag.Path = filePathImage; if (loadImage.Length > 0) { using (var stream = new FileStream(filePathImage, FileMode.Create)) { loadImage.CopyToAsync(stream); stream.Dispose(); } } Picture tempPicture = new Picture(); tempPicture.CaseID = tempCase.ID; tempPicture.PictureName = loadImage.FileName; tempCase.Pictures.Add(tempPicture); } catch (Exception ee) { } try { if (events.Count() != 0) { tempCase.Event += "\n" + events; } } catch (Exception eee) { //ingen event parameter inskickad } try { if (information.Count() != 0) { tempCase.Info += "\n" + information; } } catch (Exception eeee) { //ingen information parameter inskickad } if (!status.StatusName.Equals("Välj")) //Något måste vara valt { tempCase.Status = status.StatusName; } mymodel.SaveCase(tempCase); //sparar information och koppling i DB return(RedirectToAction("StartInvestigator")); //Återvänder till StartInvestigator }