Ejemplo n.º 1
0
        public IHttpActionResult GetAddress(long id)
        {
            Form form = null;

            using (var ctx = new WebFormEntity())
            {
                form = ctx.TestAddresses.Where(s => s.Id == id).Select(s => new Form()
                {
                    Id           = s.Id,
                    AddressLine0 = s.AddressLine0,
                    AddressLine1 = s.AddressLine1,
                    AddressLine2 = s.AddressLine2,
                    Country      = s.Country,
                    Region       = s.Region,
                    Locale       = s.Locale,
                    Code         = s.Code
                }).FirstOrDefault <Form>();
            }
            if (form == null)
            {
                return(NotFound());
            }
            return(Ok(form));
        }
Ejemplo n.º 2
0
        public IHttpActionResult GetAllAddresses()
        {
            IList <Form> forms = null;

            using (var ctx = new WebFormEntity())
            {
                forms = ctx.TestAddresses.Select(s => new Form()
                {
                    Id           = s.Id,
                    AddressLine0 = s.AddressLine0,
                    AddressLine1 = s.AddressLine1,
                    AddressLine2 = s.AddressLine2,
                    Country      = s.Country,
                    Region       = s.Region,
                    Locale       = s.Locale,
                    Code         = s.Code
                }).ToList <Form>();
            }
            if (forms == null)
            {
                return(NotFound());
            }
            return(Ok(forms));
        }