public ActionResult Details(int id) { ShowApplication ModelView = new ShowApplication(); //Using the Show Application View Model //Find the application by Id from the database string url = "ApplicationData/FindApplication/" + id; HttpResponseMessage response = client.GetAsync(url).Result; //Response 200 code if it is ok if (response.IsSuccessStatusCode) { ApplicationDto SelectedApplication = response.Content.ReadAsAsync <ApplicationDto>().Result; ModelView.Application = SelectedApplication; //Errors n/a if it is null //Associated Application with User url = "ApplicationData/GetUserForApplication/" + id; response = client.GetAsync(url).Result; ApplicationUserDto SelectedUser = response.Content.ReadAsAsync <ApplicationUserDto>().Result; ModelView.ApplicationUser = SelectedUser; //Errors n/a if it is null //Associated application with Job url = "ApplicationData/GetJobForApplication/" + id; response = client.GetAsync(url).Result; JobDto SelectedJob = response.Content.ReadAsAsync <JobDto>().Result; ModelView.Job = SelectedJob; return(View(ModelView)); } else { return(RedirectToAction("Error")); } }
public IHttpActionResult GetAllApplications() { //List of the Application from the database List <Application> Applications = db.Applications.ToList(); //Using the ShowApplication View Model List <ShowApplication> ApplicationDtos = new List <ShowApplication> { }; foreach (var Application in Applications) { ShowApplication application = new ShowApplication(); //Get the user from the OurUsers Database and link them with the application ApplicationUser ApplicationUser = db.Users .Where(c => c.Applications .Any(a => a.ApplicationId == Application.ApplicationId)) .FirstOrDefault(); ApplicationUserDto firstUser = new ApplicationUserDto { Id = ApplicationUser.Id, FirstName = ApplicationUser.FirstName, LastName = ApplicationUser.LastName, Email = ApplicationUser.Email, PhoneNumber = ApplicationUser.PhoneNumber, Address = ApplicationUser.Address, }; //Get the Job from Jobs Table and associate them with the application Job Job = db.Jobs .Where(j => j.Applications .Any(a => a.ApplicationId == Application.ApplicationId)) .FirstOrDefault(); JobDto job = new JobDto { Position = Job.Position, Category = Job.Category, Type = Job.Type, Requirement = Job.Requirement, Deadline = Job.Deadline }; ApplicationDto NewApplication = new ApplicationDto { ApplicationId = Application.ApplicationId, Comment = Application.Comment, JobId = Application.JobId, Id = Application.Id }; application.Application = NewApplication; application.Job = job; application.ApplicationUser = firstUser; ApplicationDtos.Add(application); } return(Ok(ApplicationDtos)); }
public void SetUp() { _sut = TestUtility.CreateShowApplication(); }
public void SetUp() { _mazeService = Substitute.For <IMazeService>(); _sut = new ShowApplication(_mazeService); _getShowRequest = new GetShowRequest(); }