public ActionResult TaskDetails(int id)
        {
            var task            = projectsService.GetTask(id);
            var project         = projectsService.GetProject(task.ProjectId);
            var invoicesRelated = invoicesService.SearchInvoices(i => i.MilestoneId == task.TaskId).Select(inv => new RelatedEntity()
            {
                EntityNumber = inv.InvoiceNumber, EntityType = "Invoice", IsFinished = false, ID = inv.InvoiceId, URL = Url.Action("InvoiceDetails", "Financial", new { id = inv.InvoiceId })
            });
            var jobsRelated = jobsService.SearchJobs(j => j.ProjectTaskId == task.TaskId).Select(job => new RelatedEntity()
            {
                EntityNumber = job.JobNumber, EntityType = "Job", IsFinished = false, ID = job.JobId, URL = Url.Action("JobsDetails", "Contracts", new { id = job.JobId })
            });
            var posRelated = pOsService.GetProjectPOs(task.ProjectId).Where(po => po.ProjectTaskId == task.TaskId).Select(po => new RelatedEntity()
            {
                EntityNumber = po.PONumber, EntityType = "Purchase Order", IsFinished = false, ID = po.PoId, URL = Url.Action("POsDetails", "Contracts", new { id = po.PoId })
            });
            var relatedEntities = new List <RelatedEntity>();

            relatedEntities.AddRange(invoicesRelated);
            relatedEntities.AddRange(jobsRelated);
            relatedEntities.AddRange(posRelated);

            var viewModel = new TaskViewModel()
            {
                Project         = project,
                Site            = sitesService.GetSite(project.SiteId),
                Task            = task,
                RelatedEntities = relatedEntities
            };

            ViewData["projectsManagement"] = "active in";
            ViewData["projectStatus"]      = "active";
            return(View(viewModel));
        }
 public IHttpActionResult GetSite(int siteId)
 {
     if (siteId <= 0)
     {
         return(BadRequest("site Id not passed"));
     }
     try
     {
         return(Ok(sitesService.GetSite(siteId)));
     }
     catch (Exception ex)
     {
         return(InternalServerError(ex));
     }
 }
 public ActionResult SitesDetails(int id)
 {
     ViewData["contractsManagement"] = "in";
     ViewData["sites"] = "active";
     return(View(sitesService.GetSite(id)));
 }