예제 #1
0
        public IActionResult UpdateInvestigation(Errand errand, IFormFile picture, IFormFile sample)
        {
            int TempId = int.Parse(TempData["TempId"].ToString());

            Errand CurrentErrand = repository.GetErrand(TempId);

            // If a new status is chosen and it doesn't match the already selected one.
            if (errand.StatusId != CurrentErrand.StatusId && errand.StatusId != "Välj")
            {
                CurrentErrand.StatusId = errand.StatusId;

                // Both picture and sample need to implement saving of multiple pictures/samples.
                // TODO - get ICollection -> add(newthingy) -> save updated list/collection.
                if (picture != null)
                {
                    string         path   = UploadFile(picture);
                    List <Picture> newPic = new List <Picture>();
                    newPic.Add(new Picture {
                        PictureName = path, ErrandId = CurrentErrand.ErrandId
                    });
                    repository.SavePic(newPic);
                    CurrentErrand.Pictures = newPic;
                }
                if (sample != null)
                {
                    string        path    = UploadFile(sample);
                    List <Sample> newSamp = new List <Sample>();
                    newSamp.Add(new Sample {
                        SampleName = path, ErrandId = CurrentErrand.ErrandId
                    });
                    repository.SaveSamp(newSamp);
                    CurrentErrand.Samples = newSamp;
                }

                if (errand.InvestigatorInfo != null)
                {
                    CurrentErrand.InvestigatorInfo += errand.InvestigatorInfo;
                }
                if (errand.InvestigatorAction != null)
                {
                    CurrentErrand.InvestigatorAction += errand.InvestigatorAction;
                }
            }

            repository.SaveErrand(CurrentErrand);

            return(RedirectToAction("CrimeInvestigator", new { id = TempId }));
        }
예제 #2
0
        public IActionResult UpdateDepartment(Department department)
        {
            int    TempId = int.Parse(TempData["TempId"].ToString());
            string DepId  = department.DepartmentId;

            if (ModelState.IsValid && DepId != "Välj")
            {
                // Select the last 2 characters of the department id, which should be an interger.
                string SubDepId = DepId.Substring(DepId.Length - 2);
                int    DepIdInt = int.Parse(SubDepId);

                // Checking if > 0 since all departments with an id above 0 is eligible.
                if (DepIdInt > 0)
                {
                    Errand CurrentErrand = repository.GetErrand(TempId);
                    CurrentErrand.DepartmentId = department.DepartmentId;
                    repository.SaveErrand(CurrentErrand);
                }
            }

            return(RedirectToAction("CrimeCoordinator", new { id = TempId }));
        }
예제 #3
0
        public IActionResult AssignErrand(Errand errand)
        {
            int TempId = int.Parse(TempData["TempId"].ToString());

            Errand CurrentErrand = repository.GetErrand(TempId);

            // If the checkbox is checked.
            if (errand.InvestigatorAction == "true")
            {
                CurrentErrand.StatusId         = "S_B";
                CurrentErrand.InvestigatorInfo = errand.InvestigatorInfo;
            }
            // If the checkbox isn't checked, an employee is chosen and there is a department assigned to the errand.
            else if (errand.EmployeeId != "Välj" && CurrentErrand.DepartmentId != null)
            {
                CurrentErrand.EmployeeId = errand.EmployeeId;
                CurrentErrand.StatusId   = "S_C";
            }

            repository.SaveErrand(CurrentErrand);

            return(RedirectToAction("CrimeManager", new { id = TempId }));
        }