Пример #1
0
        public void Put(Guid id, [FromBody] SharedEvent value)
        {
            var tempValue = model.Events.SingleOrDefault(x => x.PK_EventID == id);

            if (!String.IsNullOrEmpty(value.City))
            {
                tempValue.City = value.City;
            }
            if (value.Date != DateTime.MinValue)
            {
                tempValue.Date = value.Date;
            }
            if (!String.IsNullOrEmpty(value.Description))
            {
                tempValue.Description = value.Description;
            }
            if (!String.IsNullOrEmpty(value.Image))
            {
                tempValue.Image = value.Image;
            }
            if (!String.IsNullOrEmpty(value.Name))
            {
                tempValue.Name = value.Name;
            }
            if (!String.IsNullOrEmpty(value.Street))
            {
                tempValue.Street = value.Street;
            }
            if (!String.IsNullOrEmpty(value.ZipCode))
            {
                tempValue.Zipcode = value.ZipCode;
            }

            model.SaveChanges();
        }
Пример #2
0
 public void Post([FromBody] SharedEvent value)
 {
     model.Events.Add(new Event()
     {
         City         = value.City,
         Date         = value.Date,
         Description  = value.Description,
         FK_CompanyID = value.FK_CompanyID,
         Image        = value.Image,
         Name         = value.Name,
         PK_EventID   = value.PK_EventID,
         Street       = value.Street,
         Zipcode      = value.ZipCode
     });
     model.SaveChanges();
 }
Пример #3
0
        private async void GetData(Guid id)
        {
            // Get the Event
            HttpClient client = new HttpClient();
            string     res    = await client.GetStringAsync(new Uri("http://localhost:51070/api/event/" + id));

            SharedEvent resEvent = JsonConvert.DeserializeObject <SharedEvent>(res);

            PK_EventID  = resEvent.PK_EventID;
            Name        = resEvent.Name;
            Date        = resEvent.Date;
            Street      = resEvent.Street;
            ZipCode     = resEvent.ZipCode;
            City        = resEvent.City;
            Image       = resEvent.Image;
            Description = resEvent.Description;
        }
Пример #4
0
        private async void Update()
        {
            SharedEvent tempEvent = new SharedEvent()
            {
                Name        = Name,
                Date        = Date.DateTime,
                Street      = Street,
                ZipCode     = ZipCode,
                City        = City,
                Image       = Image,
                Description = Description
            };

            if (PK_EventID == Guid.Empty)
            {
                tempEvent.PK_EventID = Guid.NewGuid();

                string     tempUserId = (string)Windows.Storage.ApplicationData.Current.LocalSettings.Values["CurrentUser"];
                HttpClient client     = new HttpClient();
                string     temp       = await client.GetStringAsync(new Uri("http://localhost:51070/api/User/" + tempUserId));

                SharedUser user = JsonConvert.DeserializeObject <SharedUser>(temp);
                tempEvent.FK_CompanyID = user.FK_CompanyID;

                var myContent   = JsonConvert.SerializeObject(tempEvent);
                var buffer      = System.Text.Encoding.UTF8.GetBytes(myContent);
                var byteContent = new ByteArrayContent(buffer);
                byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
                var newEvent = await client.PostAsync(new Uri("http://localhost:51070/api/Event/"), byteContent);
            }
            else
            {
                HttpClient client      = new HttpClient();
                var        myContent   = JsonConvert.SerializeObject(tempEvent);
                var        buffer      = System.Text.Encoding.UTF8.GetBytes(myContent);
                var        byteContent = new ByteArrayContent(buffer);
                byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
                var result = await client.PutAsync(new Uri("http://localhost:51070/api/Event/" + PK_EventID), byteContent);
            }

            NavigationService.Navigate(typeof(Views.UserAdministrationPage));
        }