// GET: api/Stores
        public HttpResponseMessage Get()
        {
            try
            {
                var listadoTiendas = new StoreCollection();
                using (var ctx = SharePoint.GetContext(userName, passWord, webURL))
                {
                    listadoTiendas.GetFromSharePoint(ctx);
                }

                return(Request.CreateResponse(HttpStatusCode.OK, listadoTiendas));
            }
            catch (Exception ex)
            {
                var msg = new HttpResponseMessage()
                {
                    StatusCode = HttpStatusCode.InternalServerError,
                    Content    = new StringContent(ex.Message)
                };

                return(msg);
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            try
            {
                using (var ctx = SharePoint.GetContext(userName, passWord, webURL))
                {
                    var tienda = new Store()
                    {
                        Description = string.Format("Prueba de creación a las {0}", DateTime.Now.ToShortTimeString()),
                        Responsable = "*****@*****.**",
                        Provincia   = "España",
                        OpenDate    = DateTime.Now,
                        Tipo        = Store.TipoTienda.Franquicias
                    };

                    tienda.SaveInSharePoint(ctx);
                    Console.WriteLine("Tienda creada con ID: {0}", tienda.key);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("An error occurred:{0}", ex.Message);
            }
        }