Example #1
0
        public void Put(Guid id, [FromBody] SharedCompany value)
        {
            var tempValue = model.Companies.SingleOrDefault(x => x.PK_CompanyID == id);

            if (!String.IsNullOrEmpty(value.City))
            {
                tempValue.City = value.City;
            }
            if (!String.IsNullOrEmpty(value.Facebook))
            {
                tempValue.Facebook = value.Facebook;
            }
            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;
            }
            if (!String.IsNullOrEmpty(value.Description))
            {
                tempValue.Description = value.Description;
            }

            model.SaveChanges();
        }
Example #2
0
        private async void GetData()
        {
            // Get the User
            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);

            PK_UserID = user.PK_UserID;
            UserName  = user.UserName;
            Firstname = user.FirstName;
            Lastname  = user.LastName;
            Birthday  = user.DateOfBirth;
            Type      = user.Type;


            if (user.Type == "Entrepreneur")
            {
                Visible = Visibility.Visible;

                // Get the Company
                temp = await client.GetStringAsync(new Uri("http://localhost:51070/api/Company/" + user.FK_CompanyID));

                SharedCompany company = JsonConvert.DeserializeObject <SharedCompany>(temp);
                FK_CompanyID = user.FK_CompanyID;
                CompanyName  = company.Name;
                Street       = company.Street;
                Postalcode   = company.ZipCode;
                City         = company.City;
                Facebook     = company.Facebook;
                Image        = company.Image;
                Description  = company.Description;

                // Get the Events
                temp = await client.GetStringAsync(new Uri("http://localhost:51070/api/Event?companyID=" + user.FK_CompanyID));

                Events = new ObservableCollection <SharedEvent>(JsonConvert.DeserializeObject <List <SharedEvent> >(temp));

                // Get the Promotions
                temp = await client.GetStringAsync(new Uri("http://localhost:51070/api/Promotion?companyID=" + user.FK_CompanyID));

                Promotions = new ObservableCollection <SharedPromotion>(JsonConvert.DeserializeObject <List <SharedPromotion> >(temp));
            }
            else
            {
                Visible = Visibility.Collapsed;
            }
        }
Example #3
0
        public void Post([FromBody] SharedCompany value)
        {
            model.Companies.Add(new Company()
            {
                City          = value.City,
                Facebook      = value.Facebook,
                FK_CategoryID = value.FK_CategoryID,
                Image         = value.Image,
                Name          = value.Name,
                PK_CompanyID  = value.PK_CompanyID,
                Street        = value.Street,
                Zipcode       = value.ZipCode,
                Description   = value.Description
            });

            model.SaveChanges();
        }
Example #4
0
        private async void Update()
        {
            var list = new List <bool>();

            list.Add(this.Firstname != null && this.Firstname.Length > 0); //1
            list.Add(this.Lastname != null && this.Lastname.Length > 0);   //2
            list.Add(this.UserName != null && this.UserName.Length > 0);   //3
            list.Add(this.Password == this.PasswordConfirm);               //4
            list.Add(this.Password == this.PasswordConfirm);               //5
            list.Add(this.Birthday != null);                               //6
            if (this.CompanyName != null)
            {
                list.Add(this.CompanyName != null && this.CompanyName?.Length > 0); //7
                list.Add(this.Street != null && this.Street?.Length > 0);           //8
                list.Add(this.Postalcode != null && this.Postalcode?.Length > 0);   //9
                list.Add(this.City != null && this.City?.Length > 0);               //10
                list.Add(this.Facebook != null && this.Facebook.Length > 0);        //11
                list.Add(this.Image != null && this.Image.Length > 0);              //12
                list.Add(this.Description != null && this.Description.Length > 0);  //13
            }
            Formcontrol = list;
            if (Formcontrol.Count > 0)
            {
                FormControl1 = Formcontrol.ElementAt(0) ? green : red; //1
                FormControl2 = Formcontrol.ElementAt(1) ? green : red; //2
                FormControl3 = Formcontrol.ElementAt(2) ? green : red; //3
                FormControl4 = Formcontrol.ElementAt(3) ? green : red; //4
                FormControl5 = Formcontrol.ElementAt(4) ? green : red; //5
                FormControl6 = Formcontrol.ElementAt(5) ? green : red; //6
                if (this.CompanyName != null)
                {
                    FormControl7  = Formcontrol.ElementAt(6) ? green : red;  //7
                    FormControl8  = Formcontrol.ElementAt(7) ? green : red;  //8
                    FormControl9  = Formcontrol.ElementAt(8) ? green : red;  //9
                    FormControl10 = Formcontrol.ElementAt(9) ? green : red;  //10
                    FormControl11 = Formcontrol.ElementAt(10) ? green : red; //11
                    FormControl12 = Formcontrol.ElementAt(11) ? green : red; //12
                    FormControl13 = Formcontrol.ElementAt(12) ? green : red; //13
                }
            }
            if (Formcontrol.All(f => f))
            {
                SharedUser tempUser = new SharedUser()
                {
                    DateOfBirth = Birthday.DateTime,
                    FirstName   = Firstname,
                    LastName    = Lastname,
                    Password    = HashMethods.ComputeMD5(Password),
                    UserName    = UserName
                };
                HttpClient client      = new HttpClient();
                var        myContent   = JsonConvert.SerializeObject(tempUser);
                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/User/" + PK_UserID), byteContent);

                if (Type == "Entrepreneur")
                {
                    SharedCompany tempCompany = new SharedCompany()
                    {
                        City        = City,
                        Description = Description,
                        Facebook    = Facebook,
                        Name        = CompanyName,
                        Street      = Street,
                        ZipCode     = Postalcode,
                        Image       = Image
                    };
                    myContent   = JsonConvert.SerializeObject(tempCompany);
                    buffer      = System.Text.Encoding.UTF8.GetBytes(myContent);
                    byteContent = new ByteArrayContent(buffer);
                    byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
                    result = await client.PutAsync(new Uri("http://localhost:51070/api/Company/" + FK_CompanyID), byteContent);
                }
                FormControl1 = gray;
                FormControl2 = gray;
                FormControl3 = gray;
                FormControl4 = gray;
                FormControl5 = gray;
                FormControl6 = gray;
                if (this.CompanyName != null)
                {
                    FormControl7  = gray;
                    FormControl8  = gray;
                    FormControl9  = gray;
                    FormControl10 = gray;
                    FormControl11 = gray;
                    FormControl12 = gray;
                    FormControl13 = gray;
                }
                NavigationService.Navigate(typeof(Views.MainPage));
            }
        }