public async void DeleteProfilePhone(int _box, int _profilePhoneId)
        {
            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_ProfilePhone box_ProfilePhone = new Box_ProfilePhone
            {
                BoxId          = _box,
                ProfilePhoneId = _profilePhoneId
            };
            var apiSecurity = Application.Current.Resources["APISecurity"].ToString();
            var idBox_Phone = await this.apiService.GetIdRelation(
                apiSecurity,
                "/api",
                "/Box_ProfilePhone/GetBox_ProfilePhone",
                box_ProfilePhone);

            var profilePhone = await this.apiService.Delete(
                apiSecurity,
                "/api",
                "/Box_ProfilePhone",
                idBox_Phone.Box_ProfilePhoneId);
        }
Exemple #2
0
        public async Task <IHttpActionResult> PutBox_ProfilePhone(int id, Box_ProfilePhone box_ProfilePhone)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != box_ProfilePhone.Box_ProfilePhoneId)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
        //Obtener lista Phone
        private async Task <ObservableCollection <ProfilePhone> > GetListPhone(int _BoxId)
        {
            this.IsRunning = true;
            List <ProfilePhone> listPhone;

            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();

            ProfilePhone = new ObservableCollection <ProfilePhone>();
            listPhone    = await this.apiService.GetListByUser <ProfilePhone>(
                apiSecurity,
                "/api",
                "/ProfilePhones",
                MainViewModel.GetInstance().User.UserId);

            foreach (ProfilePhone ItemPhone in listPhone)
            {
                Box_ProfilePhone RelationPhone;
                RelationPhone = new Box_ProfilePhone
                {
                    BoxId          = _BoxId,
                    ProfilePhoneId = ItemPhone.ProfilePhoneId
                };
                apiSecurity = Application.Current.Resources["APISecurity"].ToString();
                var response = await this.apiService.Get(
                    apiSecurity,
                    "/api",
                    "/Box_ProfilePhone/GetBox_ProfilePhone",
                    RelationPhone);

                ItemPhone.Exist = response.IsSuccess;
            }

            var ListOrderBy = listPhone.OrderBy(x => x.Name).ToList();

            foreach (ProfilePhone profPhone in ListOrderBy)
            {
                ProfilePhone.Add(profPhone);
            }

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

            db.Box_ProfilePhone.Remove(box_ProfilePhone);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Exemple #5
0
        public async Task <bool> GetListPhone(int _UserId, int _BoxId)
        {
            try
            {
                List <ProfilePhone> listPhone = new List <ProfilePhone>();
                var apiSecurity = Application.Current.Resources["APISecurity"].ToString();
                listPhone = await this.apiService.GetListByUser <ProfilePhone>(
                    apiSecurity,
                    "/api",
                    "/ProfilePhones",
                    _UserId);

                foreach (ProfilePhone ItemPhone in listPhone)
                {
                    Box_ProfilePhone RelationPhone;
                    RelationPhone = new Box_ProfilePhone
                    {
                        BoxId          = _BoxId,
                        ProfilePhoneId = ItemPhone.ProfilePhoneId
                    };

                    var response = await this.apiService.Get(
                        apiSecurity,
                        "/api",
                        "/Box_ProfilePhone/GetBox_ProfilePhone",
                        RelationPhone);

                    ItemPhone.Exist = response.IsSuccess;
                    if (ItemPhone.Exist == true)
                    {
                        var foreingProfile = new ForeingProfile
                        {
                            BoxId       = _BoxId,
                            UserId      = ItemPhone.UserId,
                            ProfileName = ItemPhone.Name,
                            value       = ItemPhone.Number,
                            ProfileType = "Phone"
                        };
                        //Crear perfil de teléfono de box local predeterminada
                        using (var connSQLite = new SQLite.SQLiteConnection(App.root_db))
                        {
                            connSQLite.Insert(foreingProfile);
                        }
                    }
                }
                NotNull2 = true;
                return(NotNull2);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                NotNull2 = false;
                return(NotNull2);
            }
        }
Exemple #6
0
        public async Task <IHttpActionResult> PostBox_ProfilePhone(Box_ProfilePhone box_ProfilePhone)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Box_ProfilePhone.Add(box_ProfilePhone);
            await db.SaveChangesAsync();

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

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

            if (box_ProfilePhone == null)
            {
                return(HttpNotFound());
            }
            return(View(box_ProfilePhone));
        }
        // GET: Box_ProfilePhone/Edit/5
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Box_ProfilePhone box_ProfilePhone = await db.Box_ProfilePhone.FindAsync(id);

            if (box_ProfilePhone == null)
            {
                return(HttpNotFound());
            }
            ViewBag.BoxId          = new SelectList(db.Boxes, "BoxId", "Name", box_ProfilePhone.BoxId);
            ViewBag.ProfilePhoneId = new SelectList(db.ProfilePhones, "ProfilePhoneId", "Name", box_ProfilePhone.ProfilePhoneId);
            return(View(box_ProfilePhone));
        }
Exemple #10
0
        private async Task <ObservableCollection <ProfilePhone> > GetListPhone(int _BoxId)
        {
            this.IsRunning = true;
            List <ProfilePhone> listPhone;
            var apiSecurity = Application.Current.Resources["APISecurity"].ToString();

            ProfilePhone = new ObservableCollection <ProfilePhone>();
            listPhone    = await this.apiService.GetListByUser <ProfilePhone>(
                apiSecurity,
                "/api",
                "/ProfilePhones",
                MainViewModel.GetInstance().User.UserId);

            var ListOrderBy = listPhone.OrderBy(x => x.Name).ToList();

            foreach (ProfilePhone ItemPhone in ListOrderBy)
            {
                Box_ProfilePhone RelationPhone;
                RelationPhone = new Box_ProfilePhone
                {
                    BoxId          = _BoxId,
                    ProfilePhoneId = ItemPhone.ProfilePhoneId
                };

                var response = await this.apiService.Get(
                    apiSecurity,
                    "/api",
                    "/Box_ProfilePhone/GetBox_ProfilePhone",
                    RelationPhone);

                ItemPhone.Exist = response.IsSuccess;
                //if (ItemPhone.Exist == true)
                //{
                var Phone = Converter.ToProfileLocalP(ItemPhone);
                ProfilePerfiles.Add(Phone);
                //}
            }
            this.IsRunning = false;
            return(ProfilePhone);
        }