public async Task <IHttpActionResult> PutBox_ProfileWhatsapp(int id, Box_ProfileWhatsapp box_ProfileWhatsapp) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != box_ProfileWhatsapp.Box_ProfileWhatsappId) { return(BadRequest()); } db.Entry(box_ProfileWhatsapp).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!Box_ProfileWhatsappExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async void DeleteProfileWhatsapp(int _box, int _profileWhatsappId) { 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_ProfileWhatsapp box_ProfileWhatsapp = new Box_ProfileWhatsapp { BoxId = _box, ProfileWhatsappId = _profileWhatsappId }; var apiSecurity = Application.Current.Resources["APISecurity"].ToString(); var idBox_Whatsapp = await this.apiService.GetIdRelation( apiSecurity, "/api", "/Box_ProfileWhatsapp/GetBox_ProfileWhatsapp", box_ProfileWhatsapp); var profileWhatsapp = await this.apiService.Delete( apiSecurity, "/api", "/Box_ProfileWhatsapp", idBox_Whatsapp.Box_ProfileWhatsappId); }
//Obtener lista Whatsapp private async Task <ObservableCollection <ProfileWhatsapp> > GetListWhatsapp(int _BoxId) { this.IsRunning = true; List <ProfileWhatsapp> listWhastapp; 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(); ProfileWhatsapp = new ObservableCollection <ProfileWhatsapp>(); listWhastapp = await this.apiService.GetListByUser <ProfileWhatsapp>( apiSecurity, "/api", "/ProfileWhatsapps", MainViewModel.GetInstance().User.UserId); foreach (ProfileWhatsapp ItemWhatsapp in listWhastapp) { Box_ProfileWhatsapp RelationWhatsapp; RelationWhatsapp = new Box_ProfileWhatsapp { BoxId = _BoxId, ProfileWhatsappId = ItemWhatsapp.ProfileWhatsappId }; apiSecurity = Application.Current.Resources["APISecurity"].ToString(); var response = await this.apiService.Get( apiSecurity, "/api", "/Box_ProfileWhatsapp/GetBox_ProfileWhatsapp", RelationWhatsapp); ItemWhatsapp.Exist = response.IsSuccess; } var ListOrderBy = listWhastapp.OrderBy(x => x.Name).ToList(); foreach (ProfileWhatsapp profWhatsapp in ListOrderBy) { ProfileWhatsapp.Add(profWhatsapp); } if (ProfileWhatsapp.Count == 0) { EmptyList = true; } this.IsRunning = false; return(ProfileWhatsapp); }
private async Task <ObservableCollection <ProfileWhatsapp> > GetListWhatsapp(int _BoxId) { this.IsRunning = true; List <ProfileWhatsapp> listWhatsapp; //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(); ProfileWhatsapp = new ObservableCollection <ProfileWhatsapp>(); listWhatsapp = await this.apiService.GetListByUser <ProfileWhatsapp>( apiSecurity, "/api", "/ProfileWhatsapps", MainViewModel.GetInstance().User.UserId); foreach (ProfileWhatsapp ItemWhatsapp in listWhatsapp) { Box_ProfileWhatsapp RelationWhatsapp; RelationWhatsapp = new Box_ProfileWhatsapp { BoxId = _BoxId, ProfileWhatsappId = ItemWhatsapp.ProfileWhatsappId }; //apiSecurity = Application.Current.Resources["APISecurity"].ToString(); var response = await this.apiService.Get( apiSecurity, "/api", "/Box_ProfileWhatsapp/GetBox_ProfileWhatsapp", RelationWhatsapp); ItemWhatsapp.Exist = response.IsSuccess; if (ItemWhatsapp.Exist == true) { var W = Converter.ToProfileLocalW(ItemWhatsapp); ProfilePerfiles.Add(W); } } //foreach (ProfileWhatsapp profWhatsapp in listWhatsapp) //{ // if (profWhatsapp.Exist == true) // { // ProfilePerfiles.Add(profWhatsapp); // } //} this.IsRunning = false; return(ProfileWhatsapp); }
public async Task <ActionResult> DeleteConfirmed(int id) { Box_ProfileWhatsapp box_ProfileWhatsapp = await db.Box_ProfileWhatsapp.FindAsync(id); db.Box_ProfileWhatsapp.Remove(box_ProfileWhatsapp); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <bool> GetListWhatsapp(int _UserId, int _BoxId) { try { List <ProfileWhatsapp> listWhatsapp = new List <ProfileWhatsapp>(); var apiSecurity = Application.Current.Resources["APISecurity"].ToString(); listWhatsapp = await this.apiService.GetListByUser <ProfileWhatsapp>( apiSecurity, "/api", "/ProfileWhatsapps", _UserId); foreach (ProfileWhatsapp ItemWhatsapp in listWhatsapp) { Box_ProfileWhatsapp RelationWhatsapp; RelationWhatsapp = new Box_ProfileWhatsapp { BoxId = _BoxId, ProfileWhatsappId = ItemWhatsapp.ProfileWhatsappId }; //apiSecurity = Application.Current.Resources["APISecurity"].ToString(); var response = await this.apiService.Get( apiSecurity, "/api", "/Box_ProfileWhatsapp/GetBox_ProfileWhatsapp", RelationWhatsapp); ItemWhatsapp.Exist = response.IsSuccess; if (ItemWhatsapp.Exist == true) { ForeingProfile foreingProfile = new ForeingProfile { BoxId = _BoxId, UserId = ItemWhatsapp.UserId, ProfileName = ItemWhatsapp.Name, value = ItemWhatsapp.Number, ProfileType = "Whatsapp" }; //Crear perfil de whatsapp de box local predeterminada using (var connSQLite = new SQLite.SQLiteConnection(App.root_db)) { connSQLite.Insert(foreingProfile); } } } NotNull4 = true; return(NotNull4); } catch (Exception e) { Console.WriteLine(e); NotNull4 = false; return(NotNull4); } }
public async Task <ActionResult> Edit([Bind(Include = "Box_ProfileWhatsappId,BoxId,ProfilePhoneId")] Box_ProfileWhatsapp box_ProfileWhatsapp) { if (ModelState.IsValid) { db.Entry(box_ProfileWhatsapp).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.BoxId = new SelectList(db.Boxes, "BoxId", "Name", box_ProfileWhatsapp.BoxId); return(View(box_ProfileWhatsapp)); }
public async Task <IHttpActionResult> PostBox_ProfileWhatsapp(Box_ProfileWhatsapp box_ProfileWhatsapp) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Box_ProfileWhatsapp.Add(box_ProfileWhatsapp); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = box_ProfileWhatsapp.Box_ProfileWhatsappId }, box_ProfileWhatsapp)); }
// GET: Box_ProfileWhatsapp/Details/5 public async Task <ActionResult> Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Box_ProfileWhatsapp box_ProfileWhatsapp = await db.Box_ProfileWhatsapp.FindAsync(id); if (box_ProfileWhatsapp == null) { return(HttpNotFound()); } return(View(box_ProfileWhatsapp)); }
// GET: Box_ProfileWhatsapp/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Box_ProfileWhatsapp box_ProfileWhatsapp = await db.Box_ProfileWhatsapp.FindAsync(id); if (box_ProfileWhatsapp == null) { return(HttpNotFound()); } ViewBag.BoxId = new SelectList(db.Boxes, "BoxId", "Name", box_ProfileWhatsapp.BoxId); return(View(box_ProfileWhatsapp)); }
private async Task <ObservableCollection <ProfileWhatsapp> > GetListWhatsapp(int _BoxId) { this.IsRunning = true; List <ProfileWhatsapp> listWhatsapp; var apiSecurity = Application.Current.Resources["APISecurity"].ToString(); ProfileWhatsapp = new ObservableCollection <ProfileWhatsapp>(); listWhatsapp = await this.apiService.GetListByUser <ProfileWhatsapp>( apiSecurity, "/api", "/ProfileWhatsapps", MainViewModel.GetInstance().User.UserId); var ListOrderBy = listWhatsapp.OrderBy(x => x.Name).ToList(); foreach (ProfileWhatsapp ItemWhatsapp in ListOrderBy) { Box_ProfileWhatsapp RelationWhatsapp; RelationWhatsapp = new Box_ProfileWhatsapp { BoxId = _BoxId, ProfileWhatsappId = ItemWhatsapp.ProfileWhatsappId }; var response = await this.apiService.Get( apiSecurity, "/api", "/Box_ProfileWhatsapp/GetBox_ProfileWhatsapp", RelationWhatsapp); ItemWhatsapp.Exist = response.IsSuccess; var W = Converter.ToProfileLocalW(ItemWhatsapp); ProfilePerfiles.Add(W); } this.IsRunning = false; return(ProfileWhatsapp); }