Example #1
0
        public List <Object> GetListClient()
        {
            List <Object> dataList = new List <object>();

            using (TeConstruyeEntities1 construyeEntities = new TeConstruyeEntities1())
            {
                try
                {
                    var clientList = construyeEntities.Clients.ToList();
                    int n          = clientList.Count;
                    if (n == 0)
                    {
                        dataList = null;
                        return(dataList);
                    }
                    else
                    {
                        for (int i = 0; i < clientList.Count; ++i)
                        {
                            ProjectsxClient_Data data = new ProjectsxClient_Data();
                            data.identification = clientList.ElementAt(i).identification;
                            data.name           = clientList.ElementAt(i).name;
                            data.lastname1      = clientList.ElementAt(i).lastname1;
                            data.lastname2      = clientList.ElementAt(i).lastname2;
                            data.phone          = clientList.ElementAt(i).phone;
                            data.email          = clientList.ElementAt(i).email;
                            var           projects = construyeEntities.Projects.Where(e => e.id_client == data.identification).ToList();
                            List <Object> lis      = new List <Object>();
                            for (int j = 0; j < projects.Count; ++j)
                            {
                                lis.Add(projects.ElementAt(j).id);
                            }
                            data.projects = lis;
                            dataList.Add(data);
                        }
                        return(dataList);
                    }
                }
                catch
                {
                    dataList = null;
                    return(dataList);
                }
            }
        }
Example #2
0
        public IHttpActionResult GetClient(string ssn)
        {
            System.Diagnostics.Debug.WriteLine("GetClient");

            if (!clientLogic.existClient(ssn))
            {
                //No se encontró el recurso code 404
                return(NotFound());
            }
            ProjectsxClient_Data client = clientLogic.GetClient(ssn);

            if (client != null)
            {
                // ok code 200
                return(Ok(client));
            }
            else
            {
                //No se pudo crear el recurso por un error interno code 500
                return(InternalServerError());
            }
        }
Example #3
0
        public ProjectsxClient_Data GetClient(string ssn)
        {
            ProjectsxClient_Data client = new ProjectsxClient_Data();

            using (TeConstruyeEntities1 construyeEntities = new TeConstruyeEntities1())
            {
                try
                {
                    if (!this.existClient(ssn))
                    {
                        client = null;
                        return(client);
                    }
                    var cli = construyeEntities.Clients.Find(ssn);
                    client.identification = cli.identification;
                    client.name           = cli.name;
                    client.lastname1      = cli.lastname1;
                    client.lastname2      = cli.lastname2;
                    client.phone          = cli.phone;
                    client.email          = cli.email;
                    var           projects = construyeEntities.Projects.Where(e => e.id_client == ssn).ToList();
                    List <Object> lis      = new List <Object>();
                    for (int j = 0; j < projects.Count; ++j)
                    {
                        lis.Add(projects.ElementAt(j).id);
                    }
                    client.projects = lis;
                    return(client);
                }
                catch (Exception E)
                {
                    client = null;
                    return(client);
                }
            }
        }