// GET: Internship/Details/5

        public async Task <ActionResult> Details(string id)
        {
            InternshipView InternshipInfo = new InternshipView();

            using (var client = new HttpClient())
            {
                //Passing service base url
                client.BaseAddress = new Uri(Baseurl);

                client.DefaultRequestHeaders.Clear();
                //Define request data format
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                string str = "api/internshipsAPI/" + id;
                //Sending request to find web api REST service resource GetAllEmployees using HttpClient
                HttpResponseMessage Res = await client.GetAsync(str);

                //Checking the response is successful or not which is sent using HttpClient
                if (Res.IsSuccessStatusCode)
                {
                    //Storing the response details recieved from web api
                    var InternshipResponse = Res.Content.ReadAsStringAsync().Result;

                    //Deserializing the response recieved from web api and storing into the Employee list
                    InternshipInfo = JsonConvert.DeserializeObject <InternshipView>(InternshipResponse);
                }
            }
            return(View(InternshipInfo));
        }
Ejemplo n.º 2
0
        public IHttpActionResult GetInternship(string internshipid)
        {
            InternshipView internship = db.Internships.Include(b => b.Company).Include(b => b.CategoriesList).Include(b => b.InternshipLocations).Include(b => b.InternshipPerks).Include(b => b.InternshipSkills).Where(item => item.Id == internshipid).Select(
                p => new InternshipView
            {
                CompanyType         = p.Company.CompanyType,
                Id                  = p.Id,
                PostedOn            = (DateTime)p.CreatedDate,
                ContactEmail        = p.ContactEmail,
                ContactMobile       = p.ContactMobile,
                C_Name              = p.Company.Name,
                AboutCompany        = p.Company.About,
                StartDate           = p.StartDate,
                ApplyBefore         = p.ApplyBefore,
                Stipend             = p.Stipend,
                InternshipType      = p.InternshipType,
                InternshipLocations = (p.InternshipLocations.ToList()).Select(c => c.LocationsList.City).ToList(),
                InternshipPerks     = (p.InternshipPerks.ToList()).Select(
                    item => new InternshipView.Perk
                {
                    Name        = item.PerksList.Name,
                    Description = item.PerksList.Description
                }
                    ).ToList(),
                InternshipSkills = (p.InternshipSkills.ToList()).Select(c => c.SkillsList.Name).ToList(),
                About            = p.About,
                InternshipIn     = p.CategoriesList.Name,
                AvailableSeats   = p.AvailableSeats,
                MinDuration      = p.MinDuration,
                MaxDuration      = p.MaxDuration,
                stud             = (p.Applieds.ToList()).Select(c => new InternshipView.Student
                {
                    S_Id   = c.S_Id,
                    S_Name = c.Student.FirstName + " " + c.Student.LastName,
                    Status = c.Status
                }).ToList()
            }
                ).OrderBy(p => p.ApplyBefore).FirstOrDefault();

            if (internship == null)
            {
                return(NotFound());
            }

            return(Ok(internship));
        }