public async Task <IHttpActionResult> PutBox_ProfileSM(int id, Box_ProfileSM box_ProfileSM)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != box_ProfileSM.Box_ProfileSMId)
            {
                return(BadRequest());
            }

            db.Entry(box_ProfileSM).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!Box_ProfileSMExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public async void DeleteProfileSM(int _box, int _profileSMId)
        {
            var connection = await this.apiService.CheckConnection();

            if (!connection.IsSuccess)
            {
                await Application.Current.MainPage.DisplayAlert(
                    Languages.Error,
                    connection.Message,
                    Languages.Accept);

                await App.Navigator.PopAsync();
            }

            Box_ProfileSM box_ProfileSM = new Box_ProfileSM
            {
                BoxId       = _box,
                ProfileMSId = _profileSMId
            };
            var apiSecurity = Application.Current.Resources["APISecurity"].ToString();
            var idBox_SM    = await this.apiService.GetIdRelation(
                apiSecurity,
                "/api",
                "/Box_ProfileSM/GetBox_ProfileSM",
                box_ProfileSM);

            var profileSM = await this.apiService.Delete(
                apiSecurity,
                "/api",
                "/Box_ProfileSM",
                idBox_SM.Box_ProfileSMId);
        }
        //Obtener lista SM
        private async Task <ObservableCollection <ProfileSM> > GetListSM(int _BoxId)
        {
            this.IsRunning = true;
            List <ProfileSM> listSM;

            var connection = await this.apiService.CheckConnection();

            if (!connection.IsSuccess)
            {
                this.IsRunning = false;
                await Application.Current.MainPage.DisplayAlert(
                    Languages.Error,
                    connection.Message,
                    Languages.Accept);

                return(null);
            }

            var apiSecurity = Application.Current.Resources["APISecurity"].ToString();

            ProfileSM = new ObservableCollection <ProfileSM>();
            listSM    = await this.apiService.GetProfileByNetWork(
                apiSecurity,
                "/api",
                "/ProfileSMs/GetProfileByNetWorkT",
                MainViewModel.GetInstance().User.UserId,
                RedSocial);

            foreach (ProfileSM ItemSM in listSM)
            {
                Box_ProfileSM RelationSM;
                RelationSM = new Box_ProfileSM
                {
                    BoxId       = _BoxId,
                    ProfileMSId = ItemSM.ProfileMSId
                };

                var response = await this.apiService.Get(
                    apiSecurity,
                    "/api",
                    "/Box_ProfileSM/GetBox_ProfileSM",
                    RelationSM);

                ItemSM.Exist = response.IsSuccess;
            }

            var ListOrderBy = listSM.OrderBy(x => x.ProfileName).ToList();

            foreach (ProfileSM profSM in ListOrderBy)
            {
                ProfileSM.Add(profSM);
            }

            if (ProfileSM.Count == 0)
            {
                EmptyList = true;
            }
            this.IsRunning = false;
            return(ProfileSM);
        }
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            Box_ProfileSM box_ProfileSM = await db.Box_ProfileSM.FindAsync(id);

            db.Box_ProfileSM.Remove(box_ProfileSM);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
        public async Task <IHttpActionResult> PostBox_ProfileSM(Box_ProfileSM box_ProfileSM)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Box_ProfileSM.Add(box_ProfileSM);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = box_ProfileSM.Box_ProfileSMId }, box_ProfileSM));
        }
        public async Task <ActionResult> Edit([Bind(Include = "Box_ProfileSMId,BoxId,ProfileMSId")] Box_ProfileSM box_ProfileSM)
        {
            if (ModelState.IsValid)
            {
                db.Entry(box_ProfileSM).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.BoxId       = new SelectList(db.Boxes, "BoxId", "Name", box_ProfileSM.BoxId);
            ViewBag.ProfileMSId = new SelectList(db.ProfileSMs, "ProfileMSId", "link", box_ProfileSM.ProfileMSId);
            return(View(box_ProfileSM));
        }
        // GET: Box_ProfileSM/Details/5
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Box_ProfileSM box_ProfileSM = await db.Box_ProfileSM.FindAsync(id);

            if (box_ProfileSM == null)
            {
                return(HttpNotFound());
            }
            return(View(box_ProfileSM));
        }
        private async Task <ObservableCollection <ProfileSM> > GetListSM(int _BoxId)
        {
            this.IsRunning = true;
            List <ProfileSM> listSM;
            //var connection = await this.apiService.CheckConnection();
            //if (!connection.IsSuccess)
            //{
            //    this.IsRunning = false;
            //    await Application.Current.MainPage.DisplayAlert(
            //        Languages.Error,
            //        connection.Message,
            //        Languages.Accept);
            //    return null;
            //}

            var apiSecurity = Application.Current.Resources["APISecurity"].ToString();

            ProfileSM = new ObservableCollection <ProfileSM>();
            listSM    = await this.apiService.GetListByUser <ProfileSM>(
                apiSecurity,
                "/api",
                "/ProfileSMs",
                MainViewModel.GetInstance().User.UserId);

            foreach (ProfileSM ItemSM in listSM)
            {
                Box_ProfileSM RelationSM;
                RelationSM = new Box_ProfileSM
                {
                    BoxId       = _BoxId,
                    ProfileMSId = ItemSM.ProfileMSId
                };
                //apiSecurity = Application.Current.Resources["APISecurity"].ToString();
                var response = await this.apiService.Get(
                    apiSecurity,
                    "/api",
                    "/Box_ProfileSM/GetBox_ProfileSM",
                    RelationSM);

                ItemSM.Exist = response.IsSuccess;
                if (ItemSM.Exist == true)
                {
                    var SM = Converter.ToProfileLocalSM(ItemSM);
                    ProfilePerfiles.Add(SM);
                }
            }
            this.IsRunning = false;
            return(ProfileSM);
        }
        // GET: Box_ProfileSM/Edit/5
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Box_ProfileSM box_ProfileSM = await db.Box_ProfileSM.FindAsync(id);

            if (box_ProfileSM == null)
            {
                return(HttpNotFound());
            }
            ViewBag.BoxId       = new SelectList(db.Boxes, "BoxId", "Name", box_ProfileSM.BoxId);
            ViewBag.ProfileMSId = new SelectList(db.ProfileSMs, "ProfileMSId", "link", box_ProfileSM.ProfileMSId);
            return(View(box_ProfileSM));
        }
        private async Task <ObservableCollection <ProfileSM> > GetListSM(int _BoxId)
        {
            this.IsRunning = true;
            List <ProfileSM> listSM;

            var apiSecurity = Application.Current.Resources["APISecurity"].ToString();

            ProfileSM = new ObservableCollection <ProfileSM>();
            listSM    = await this.apiService.GetListByUser <ProfileSM>(
                apiSecurity,
                "/api",
                "/ProfileSMs",
                MainViewModel.GetInstance().User.UserId);

            foreach (ProfileSM ItemSM in listSM)
            {
                Box_ProfileSM RelationSM;
                RelationSM = new Box_ProfileSM
                {
                    BoxId       = _BoxId,
                    ProfileMSId = ItemSM.ProfileMSId
                };
                //apiSecurity = Application.Current.Resources["APISecurity"].ToString();
                var response = await this.apiService.Get(
                    apiSecurity,
                    "/api",
                    "/Box_ProfileSM/GetBox_ProfileSM",
                    RelationSM);

                ItemSM.Exist = response.IsSuccess;
                if (ItemSM.Exist == true)
                {
                    var SM = Converter.ToProfileLocalSM(ItemSM);
                    ProfilePerfiles.Add(SM);
                }
            }
            this.IsRunning = false;
            return(ProfileSM);
        }
示例#11
0
        public async Task <bool> GetListSM(int _UserId, int _BoxId)
        {
            try
            {
                List <ProfileSM> listSM = new List <ProfileSM>();
                var apiSecurity         = Application.Current.Resources["APISecurity"].ToString();

                listSM = await this.apiService.GetListByUser <ProfileSM>(
                    apiSecurity,
                    "/api",
                    "/ProfileSMs",
                    _UserId);

                foreach (ProfileSM ItemSM in listSM)
                {
                    Box_ProfileSM RelationSM;
                    RelationSM = new Box_ProfileSM
                    {
                        BoxId       = _BoxId,
                        ProfileMSId = ItemSM.ProfileMSId
                    };

                    var response = await this.apiService.Get(
                        apiSecurity,
                        "/api",
                        "/Box_ProfileSM/GetBox_ProfileSM",
                        RelationSM);

                    ItemSM.Exist = response.IsSuccess;

                    if (ItemSM.Exist == true)
                    {
                        var profileSM = await this.apiService.GetRS(
                            apiSecurity,
                            "/api",
                            "/RedSocials",
                            ItemSM.RedSocialId);

                        var foreingProfileSM = new ForeingProfile
                        {
                            BoxId       = _BoxId,
                            UserId      = ItemSM.UserId,
                            ProfileName = ItemSM.ProfileName,
                            value       = ItemSM.link,
                            ProfileType = profileSM.Name,
                        };
                        //Crear perfil de redes sociales de box local predeterminada
                        using (var connSQLite = new SQLite.SQLiteConnection(App.root_db))
                        {
                            connSQLite.Insert(foreingProfileSM);
                        }
                    }
                }
                NotNull3 = true;
                return(NotNull3);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                NotNull3 = false;
                return(NotNull3);
            }
        }