Ejemplo n.º 1
0
        public MandateController()
        {
            mandateModels = new List <MandateModel>();
            mandates      = s.GetMandates();
            foreach (var m in mandates)
            {
                var req = from p in si.GetMany()
                          where p.Id == m.IdResource
                          select p;
                var           r  = req.FirstOrDefault();
                ResourceModel rm = new ResourceModel()
                {
                    FirstName = r.FirstName, LastName = r.LastName, Salary = (int)r.Salary
                };


                var reqe = from p in sii.GetMany()
                           where p.Project_id == m.IdProject
                           select p;
                var          re = reqe.FirstOrDefault();
                ProjectModel pm = new ProjectModel()
                {
                    Name = re.Name
                };


                MandateModel md = new MandateModel()
                {
                    MandateId = m.MandateId, EndDate = m.EndDate, Fees = m.Fees, IdProject = m.IdProject, IdResource = m.IdResource, StartDate = m.StartDate, Resource = rm, Project = pm, Disponibility = m.Disponibility
                };
                mandateModels.Add(md);

                if (md.StartDate >= System.DateTime.Today)
                {
                    md.Disponibility = "available";
                }

                else
                {
                    md.Disponibility = "unavailable";
                }
            }
        }
 //private MapWebContext db = new MapWebContext();
 // GET: api/APIMandate
 public IEnumerable <Mandate> GetMandate()
 {
     return(sm.GetMandates());
 }