Example #1
0
        private void btnSalvarApto_Click(object sender, EventArgs e)
        {
            try
            {
                BA   ba   = new BA();
                BABO baBO = new BABO();

                ba.Bloco = txtBloco.Text;
                ba.Apto  = txtApto.Text;
                if ((ba.Bloco != "") && (ba.Apto != ""))
                {
                    baBO.Gravar(ba);
                    MessageBox.Show("Apto cadastrado com sucesso");

                    grpCadApto.Visible = true;
                    txtBloco.Clear();
                    txtApto.Clear();
                }
                else
                {
                    MessageBox.Show("Preencha todos os campos");
                }
            }
            catch
            {
                MessageBox.Show("Verifique os dados e tente novamente");
            }
        }
Example #2
0
        public bool AddBaAsync(BA ba)
        {
            try
            {
                string url     = "http://knowhau.somee.com/api/BA";
                var    uri     = new Uri(string.Format(url, ba.baID));
                var    data    = JsonConvert.SerializeObject(ba);
                var    content = new StringContent(data, Encoding.UTF8, "application/json");
                HttpResponseMessage response = null;
                response = client.PostAsync(uri, content).Result;

                if (!response.IsSuccessStatusCode)
                {
                    return(false);

                    throw new Exception("Erro ao incluir utilizador");
                }
                return(true);
            }
            catch (Exception ex)
            {
                return(false);

                throw ex;
            }
        }
Example #3
0
        public HttpResponseMessage Put(String beaconID, [FromBody] BA BA)
        {
            try
            {
                using (knowhauEntities entities = new knowhauEntities())
                {
                    var entity = entities.BAs.FirstOrDefault(e => e.beaconID == beaconID);
                    if (entity == null)
                    {
                        return(Request.CreateErrorResponse(HttpStatusCode.NotFound,
                                                           "Beacon with id " + beaconID.ToString() + " not found to update"));
                    }
                    else
                    {
                        entity.beaconID   = BA.beaconID;
                        entity.adminemail = BA.adminemail;
                        entity.baID       = BA.baID;
                        entities.SaveChanges();

                        return(Request.CreateResponse(HttpStatusCode.OK, entity));
                    }
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }
Example #4
0
        public BA BuscaCodBA(string Apto, string Bloco)
        {
            MySqlCommand comando = new MySqlCommand();

            comando.CommandType = CommandType.Text;
            comando.CommandText = "Select * from BA where Bloco=@Bloco AND Apto=@Apto";


            comando.Parameters.AddWithValue("@Bloco", Bloco);
            comando.Parameters.AddWithValue("@Apto", Apto);


            MySqlDataReader dr = ConexaoBanco.Selecionar(comando);

            BA ba = new BA();

            if (dr.HasRows)
            {
                dr.Read();
                ba.Ba_Cod = (int)dr["Ba_Cod"];
                ba.Apto   = (string)dr["Apto"];
                ba.Bloco  = (string)dr["Bloco"];
            }
            else
            {
                ba.Ba_Cod = 0;
                ba.Apto   = "";
                ba.Bloco  = "";
            }
            return(ba);
        }
        public ActionResult DeleteConfirmed(int id)
        {
            BA bA = db.BAs.Find(id);

            db.BAs.Remove(bA);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #6
0
        public void Gravar(BA ba) //GRAVAR NOVO BLOCO/APTO
        {
            BADAO baDao = new BADAO();

            if (ba.Bloco != "")
            {
                baDao.Insert(ba);
            }
        }
Example #7
0
        public HttpResponseMessage Delete(String beaconID, string admin)
        {
            try
            {
                using (knowhauEntities entities = new knowhauEntities())
                {
                    var entity = entities.BEACONs.FirstOrDefault(e => e.beaconID == beaconID);
                    if (entity == null)
                    {
                        return(Request.CreateErrorResponse(HttpStatusCode.NotFound,
                                                           "beaconID = " + beaconID.ToString() + " not found to delete"));
                    }
                    else
                    {
                        var entity3 = entities.CONTENTs.FirstOrDefault(e => e.beaconID == entity.beaconID);
                        var entity4 = entities.HISTORICs.FirstOrDefault(e => e.contentID == entity3.contentID);
                        while (entity4 != null)
                        {
                            entities.HISTORICs.Remove(entity4);
                            entities.SaveChanges();
                            entity4 = entities.HISTORICs.FirstOrDefault(e => e.contentID == entity3.contentID);
                        }

                        while (entity3 != null)
                        {
                            entities.CONTENTs.Remove(entity3);
                            entities.SaveChanges();
                            entity3 = entities.CONTENTs.FirstOrDefault(e => e.beaconID == entity.beaconID);
                        }

                        var entity2 = entities.BAs.FirstOrDefault(e => e.beaconID == entity.beaconID);
                        while (entity2 != null)
                        {
                            entities.BAs.Remove(entity2);
                            entities.SaveChanges();
                            entity2 = entities.BAs.FirstOrDefault(e => e.beaconID == entity.beaconID);
                        }
                        entities.BEACONs.Remove(entity);
                        entities.SaveChanges();
                        BA id = new BA();
                        //id=entities.BAs.FirstOrDefault(e => e.beaconID == beaconID);
                        LOGWEBAPP web = new LOGWEBAPP();
                        web.date      = DateTime.Now;
                        web.eventtype = "D";
                        web.username  = admin;
                        entities.LOGWEBAPPs.Add(web);
                        entities.SaveChanges();
                        return(Request.CreateResponse(HttpStatusCode.OK));
                    }
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }
Example #8
0
        public override void Confirm()
        {
            bool checkSuccessful = true;
            int  n = SelectedTransforms.Length;

            while (--n > -1)
            {               // Prevents situations, when a GameObject was deleted, while being operated on
                if (SelectedTransforms[n] == null || SelectedTransforms[n].gameObject == null)
                {
                    checkSuccessful = false;
                    TerminateAction = true;
                    break;
                }
            }

            if (!checkSuccessful)
            {
                Cancel();
            }
            else
            {
                base.Confirm();

                BA.ResetTransformLock();
                // Before confirming we reverse the models to their original states to save an undo record.
                //	This is better than saving undo at the start of the trasformation because it prevents undo glitches
                //	and empty undos.
                // First - save the current sates
                Vector3        currentColliderCenter = Vector3.zero;
                List <Vector3> currentLocalPositions = new List <Vector3>();
                List <Vector3> currentEulerAngles    = new List <Vector3>();

                for (int i = 0; i < SelectedTransforms.Length; i++)
                {
                    currentLocalPositions.Add(SelectedTransforms[i].localPosition);
                    currentEulerAngles.Add(SelectedTransforms[i].eulerAngles);
                }

                // Reset the models
                ResetRotations();

                //Save an undo record
                Undo.IncrementCurrentGroup();
                for (int i = 0; i < SelectedTransforms.Length; i++)
                {
                    Undo.RecordObject(SelectedTransforms[i], "Rotate");
                }

                // Restore saved states
                for (int i = 0; i < SelectedTransforms.Length; i++)
                {
                    SelectedTransforms[i].localPosition = currentLocalPositions[i];
                    SelectedTransforms[i].eulerAngles   = currentEulerAngles[i];
                }
            }
        }
Example #9
0
        public void BuscaCodBA(BA ba)
        {
            BADAO baDao = new BADAO();

            if ((ba.Apto != "") && (ba.Bloco != ""))
            {
                var baTemp = baDao.BuscaCodBA(ba.Apto, ba.Bloco);
                ba.Ba_Cod = baTemp.Ba_Cod;
                ba.Apto   = baTemp.Apto;
                ba.Bloco  = baTemp.Bloco;
            }
        }
 public ActionResult Edit([Bind(Include = "BA_Id,Name,Username,Password,Cust_Id,Dev_Id,Proj_Id")] BA bA)
 {
     if (ModelState.IsValid)
     {
         db.Entry(bA).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Cust_Id = new SelectList(db.Customers, "Id", "Name", bA.Cust_Id);
     ViewBag.Dev_Id  = new SelectList(db.Developers, "Dev_Id", "Username", bA.Dev_Id);
     ViewBag.Proj_Id = new SelectList(db.Projects, "Id", "Title", bA.Proj_Id);
     return(View(bA));
 }
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BA bA = db.BAs.Find(id);

            if (bA == null)
            {
                return(HttpNotFound());
            }
            return(View(bA));
        }
Example #12
0
        public void DemoPatchAssembler()
        {
            string src = @"
; EnterMainMenu:      ;; commented so it doesn't complain about redefined labels
    LDA #$51
    STA music_track     ; set music track $51 (menu music)
    LDA #0
    STA $2001           ; turn off the PPU (we need to do some drawing)     
    STA $4015           ; and silence the APU.  Music sill start next time MusicPlay is called.
    JSR LoadMenuCHRPal        ; load menu related CHR and palettes
    LDX #$0B
  @Loop:                      ; load a few other main menu related palettes
      LDA lutMenuPalettes, X  ; fetch the palette from the LUT
      STA cur_pal, X          ; and write it to the palette buffer
      DEX
      BPL @Loop               ; loop until X wraps ($0C colors copied)
";
            BA     bank_and_address    = Symbols.Labels.EnterMainMenu;
            string human_readable_name = "EnterMainMenu duplicate";

            byte[] result = Assembler.Assemble(bank_and_address, human_readable_name, src);

            // this is all you have to do. The rest of the code below is just printing hex and comparing.



            string result_hex = BitConverter.ToString(result).Replace("-", string.Empty);

            Console.WriteLine("result:");
            Console.WriteLine(result_hex);

            var rom_address = bank_and_address.ToRomLocation();
            var size_guess  = Symbols.Calculate.SpaceToNextLabel("EnterMainMenu");

            byte[] from_actual_rom = Get(rom_address, size_guess);
            string rom_hex         = BitConverter.ToString(from_actual_rom).Replace("-", string.Empty);

            Console.WriteLine("from rom:");
            Console.WriteLine(rom_hex);

            if (rom_hex == result_hex)
            {
                Console.WriteLine("MATCH");
            }
            else
            {
                Console.WriteLine("mismatch");
            }
        }
        // GET: BAs/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BA bA = db.BAs.Find(id);

            if (bA == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Cust_Id = new SelectList(db.Customers, "Id", "Name", bA.Cust_Id);
            ViewBag.Dev_Id  = new SelectList(db.Developers, "Dev_Id", "Username", bA.Dev_Id);
            ViewBag.Proj_Id = new SelectList(db.Projects, "Id", "Title", bA.Proj_Id);
            return(View(bA));
        }
Example #14
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            DataGridViewRow linhaSelecionada;

            linhaSelecionada = dataGridView1.CurrentRow;


            txtApto.Text         = linhaSelecionada.Cells[0].Value.ToString();
            txtBloco.Text        = linhaSelecionada.Cells[1].Value.ToString();
            txtProprietario.Text = linhaSelecionada.Cells[2].Value.ToString();

            mskHorarioInicio.Text  = linhaSelecionada.Cells[3].Value.ToString();
            mskHorarioTermino.Text = linhaSelecionada.Cells[4].Value.ToString();
            lblCodLocacao.Text     = linhaSelecionada.Cells[5].Value.ToString();

            panel1.Enabled     = true;
            btnAlterar.Enabled = true;
            btnExcluir.Enabled = true;

            try
            {
                //puxar codigo do BA
                BA   ba   = new BA();
                BABO babo = new BABO();

                ba.Apto  = txtApto.Text;
                ba.Bloco = txtBloco.Text;

                babo.BuscaCodBA(ba);
                lblBACod.Text = Convert.ToString(ba.Ba_Cod);

                //puxar codigo do MORADOR
                Moradores   mor   = new Moradores();
                MoradoresBO morBO = new MoradoresBO();

                mor.Nome = txtProprietario.Text;
                morBO.Buscar(mor);

                lblMoradorCod.Text = Convert.ToString(mor.CodMorador);
            }
            catch
            {
                MessageBox.Show("Verifique os dados e tente novamente");
            }
        }
Example #15
0
        public void Insert(BA ba) //INSERIR BLOCO/APTO
        {
            try
            {
                MySqlCommand comando = new MySqlCommand();
                comando.CommandType = CommandType.Text;
                comando.CommandText =
                    "Insert into BA(Apto,Bloco) values(@Apto,@Bloco)";

                comando.Parameters.AddWithValue("@Apto", ba.Apto);
                comando.Parameters.AddWithValue("@Bloco", ba.Bloco);
                ConexaoBanco.CRUD(comando);
            }
            catch (Exception ex)
            {
                throw new Exception("Não foi possível se conectar" + ex.Message);
            }
        }
Example #16
0
        private static void writeOutputTxt(string[,] student, double[] studentAvg, string[] studentLetterGrade)
        {
            string path = @"output.txt";                                                     // We specify the path of the file that we will read.

            FileStream   fs = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write); // Created a file stream object.
            StreamWriter sw = new StreamWriter(fs);                                          // Created a StreamWriter object for reading.

            // Results will be printed to file and console.

            for (int i = 0; i < numberOfStudents; i++) // Will return as many as the number of students
            {
                sw.WriteLine(student[i, 0] + " " + student[i, 1] + " " + student[i, 2] + " - Student Average: " + studentAvg[i] + " - Letter Grade: " + studentLetterGrade[i]);
                Console.WriteLine(student[i, 0] + " " + student[i, 1] + " " + student[i, 2] + " - Student Average: " + studentAvg[i] + " - Letter Grade: " + studentLetterGrade[i]);
            }

            sw.WriteLine("\n- LETTER GRADE STATUS OF THE CLASS -");
            sw.WriteLine("AA: " + AA.ToString() + " Person - " + Convert.ToInt32((AA * 100) / numberOfStudents) + "% OF THE CLASS");
            sw.WriteLine("BA: " + BA.ToString() + " Person - " + Convert.ToInt32((BA * 100) / numberOfStudents) + "% OF THE CLASS");
            sw.WriteLine("BB: " + BB.ToString() + " Person - " + Convert.ToInt32((BB * 100) / numberOfStudents) + "% OF THE CLASS");
            sw.WriteLine("CB: " + CB.ToString() + " Person - " + Convert.ToInt32((CB * 100) / numberOfStudents) + "% OF THE CLASS");
            sw.WriteLine("CC: " + CC.ToString() + " Person - " + Convert.ToInt32((CC * 100) / numberOfStudents) + "% OF THE CLASS");
            sw.WriteLine("DC: " + DC.ToString() + " Person - " + Convert.ToInt32((DC * 100) / numberOfStudents) + "% OF THE CLASS");
            sw.WriteLine("DD: " + DD.ToString() + " Person - " + Convert.ToInt32((DD * 100) / numberOfStudents) + "% OF THE CLASS");
            sw.WriteLine("FD: " + FD.ToString() + " Person - " + Convert.ToInt32((FD * 100) / numberOfStudents) + "% OF THE CLASS");
            sw.WriteLine("FF: " + FF.ToString() + " Person - " + Convert.ToInt32((FF * 100) / numberOfStudents) + "% OF THE CLASS");

            Console.WriteLine("\n- LETTER GRADE STATUS OF THE CLASS -");
            Console.WriteLine("AA: " + AA.ToString() + " Person - " + Convert.ToInt32((AA * 100) / numberOfStudents) + "% OF THE CLASS");
            Console.WriteLine("BA: " + BA.ToString() + " Person - " + Convert.ToInt32((BA * 100) / numberOfStudents) + "% OF THE CLASS");
            Console.WriteLine("BB: " + BB.ToString() + " Person - " + Convert.ToInt32((BB * 100) / numberOfStudents) + "% OF THE CLASS");
            Console.WriteLine("CB: " + CB.ToString() + " Person - " + Convert.ToInt32((CB * 100) / numberOfStudents) + "% OF THE CLASS");
            Console.WriteLine("CC: " + CC.ToString() + " Person - " + Convert.ToInt32((CC * 100) / numberOfStudents) + "% OF THE CLASS");
            Console.WriteLine("DC: " + DC.ToString() + " Person - " + Convert.ToInt32((DC * 100) / numberOfStudents) + "% OF THE CLASS");
            Console.WriteLine("DD: " + DD.ToString() + " Person - " + Convert.ToInt32((DD * 100) / numberOfStudents) + "% OF THE CLASS");
            Console.WriteLine("FD: " + FD.ToString() + " Person - " + Convert.ToInt32((FD * 100) / numberOfStudents) + "% OF THE CLASS");
            Console.WriteLine("FF: " + FF.ToString() + " Person - " + Convert.ToInt32((FF * 100) / numberOfStudents) + "% OF THE CLASS");


            sw.Flush(); // txt created

            sw.Close(); // Close file
            fs.Close();
        }
        public ActionResult BAProfile()
        {
            string username = this.Session["username"].ToString();
            var    result   = from d in db.BAs
                              select d;

            var BA = result.FirstOrDefault(x => x.Username == username);

            if (BA != null)
            {
                int id = BA.BA_Id;
                BA  ba = db.BAs.Find(id);
                if (ba == null)
                {
                    return(HttpNotFound());
                }
                return(View(ba));
            }
            return(View());
        }
Example #18
0
        public override void Initialize(SpecificationBase spec)
        {
            Specification Spec    = spec as Specification;
            List <string> varList = Process.GetGlobalVariables();

            BA.Initialize(Spec.DeclarationDatabase);

            foreach (KeyValuePair <string, Expression> pair in BA.DeclarationDatabase)
            {
                varList.AddRange(pair.Value.GetVars());
            }

            Valuation GlobalEnv = Spec.SpecValuation.GetVariableChannelClone(varList, Process.GetChannels());

            InitialStep = new Configuration(Process, Constants.INITIAL_EVENT, null, GlobalEnv, false);

            MustAbstract = Process.MustBeAbstracted();

            base.Initialize(spec);
        }
Example #19
0
        private void btnConsultar_Click(object sender, EventArgs e)
        {
            BA    ba    = new BA();
            BABO  baBO  = new BABO();
            BADAO baDao = new BADAO();

            try
            {
                ba.Bloco = txtBlocoConsulta.Text;

                dataGridView1.DataSource = baDao.Consulta(txtBlocoConsulta.Text);
                for (int i = 1; i == dataGridView1.RowCount; i++)
                {
                    MessageBox.Show("Nenhum bloco encontrado");
                    txtBlocoConsulta.Clear();
                }
            }
            catch
            {
                MessageBox.Show("Preencha corretamente as informações");
            }
        }
Example #20
0
        public HttpResponseMessage Post([FromBody] BA ba)
        {
            try
            {
                using (knowhauEntities entities = new knowhauEntities())
                {
                    entities.BAs.Add(ba);
                    entities.SaveChanges();

                    var message = Request.CreateResponse(HttpStatusCode.Created, ba);
                    message.Headers.Location = new Uri(Request.RequestUri +
                                                       ba.baID.ToString());

                    return(message);
                }
            }
            catch (DbEntityValidationException ex)
            {
                // Retrieve the error messages as a list of strings.
                var errorMessages = ex.EntityValidationErrors
                                    .SelectMany(x => x.ValidationErrors)
                                    .Select(x => x.ErrorMessage);

                // Join the list to a single string.
                var fullErrorMessage = string.Join("; ", errorMessages);

                // Combine the original exception message with the new one.
                var exceptionMessage = string.Concat(ex.Message, " The validation errors are: ", fullErrorMessage);

                // Throw a new DbEntityValidationException with the improved exception message.
                throw new DbEntityValidationException(exceptionMessage, ex.EntityValidationErrors);
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }
Example #21
0
        private void btnAlterar_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < dataGridView1.RowCount; i++)
            {
                dataGridView1.Rows[i].DataGridView.Columns.Clear();
            }


            try
            {
                //pega codigo bloco apartamento
                BA   ba   = new BA();
                BABO babo = new BABO();

                ba.Apto  = txtApto.Text;
                ba.Bloco = txtBloco.Text;

                babo.BuscaCodBA(ba);

                if ((ba.Bloco == "") || (ba.Apto == ""))
                {
                    MessageBox.Show("Bloco/Apartamento não encontrado");
                    txtApto.Clear();
                    txtBloco.Clear();
                }

                else
                {
                    lblBACod.Text = Convert.ToString(ba.Ba_Cod);


                    try
                    {   //pega codigo morador
                        Moradores   mor   = new Moradores();
                        MoradoresBO morBO = new MoradoresBO();


                        mor.Nome = txtTutor.Text;
                        morBO.Buscar(mor);

                        if (mor.Nome == "")
                        {
                            MessageBox.Show("Tutor não encontrado");
                            txtTutor.Clear();
                        }

                        else
                        {
                            lblMoradorCod.Text = Convert.ToString(mor.CodMorador);
                            //altera o pet
                            try
                            {
                                Pets   pets   = new Pets();
                                PetsBO petsBO = new PetsBO();
                                pets.Nome = txtNome.Text;


                                if ((pets.Nome == "") || (pets.Nome == null))
                                {
                                    MessageBox.Show("Nome do pet não identificado");
                                }
                                else
                                {
                                    pets.CodPet = Convert.ToInt16(lblCodPet.Text);
                                    pets.Nome   = txtNome.Text.ToUpper();
                                    pets.Moradores.CodMorador = Convert.ToInt16(lblMoradorCod.Text);
                                    pets.BA.Ba_Cod            = Convert.ToInt16(lblBACod.Text);
                                    pets.Especie = cbbEspecie.SelectedItem.ToString();

                                    petsBO.Editar(pets);
                                    MessageBox.Show("Pet editado com sucesso");

                                    txtNome.Clear();
                                    txtApto.Clear();
                                    txtBloco.Clear();;
                                    txtTutor.Clear();
                                    cbbEspecie.SelectedIndex = -1;
                                    txtBusca.Clear();
                                    panel1.Enabled     = false;
                                    btnAlterar.Enabled = false;
                                    btnExcluir.Enabled = false;
                                    lblCodPet.Text     = "";
                                }
                            }
                            catch
                            {
                                MessageBox.Show("Verifique os dados e tente novamente");
                            }
                        }
                    }

                    catch
                    {
                        MessageBox.Show("Verifique os dados e tente novamente");
                    }
                }
            }
            catch
            {
                MessageBox.Show("Verifique os dados e tente novamente");
            }
        }
Example #22
0
        private void btnCadastrar_Click(object sender, EventArgs e)
        {
            try
            {
                //puxar codigo do ba
                BA   ba   = new BA();
                BABO babo = new BABO();

                ba.Apto  = txtApto.Text;
                ba.Bloco = txtBloco.Text;

                babo.BuscaCodBA(ba);

                if ((ba.Bloco == "") || (ba.Apto == ""))
                {
                    MessageBox.Show("Bloco/Apartamento não encontrado");
                    txtBloco.Clear();
                    txtApto.Clear();
                }

                else
                {
                    lblBACod.Text = Convert.ToString(ba.Ba_Cod);
                    //ouxar codigo do morador
                    try
                    {
                        Moradores   mor   = new Moradores();
                        MoradoresBO morBO = new MoradoresBO();


                        mor.Nome = txtProprietario.Text;
                        morBO.Buscar(mor);

                        if (mor.Nome == "")
                        {
                            MessageBox.Show("Proprietário não encontrado");
                            txtProprietario.Clear();
                        }

                        else
                        {
                            lblMoradorCod.Text = Convert.ToString(mor.CodMorador);

                            try
                            {
                                //add obras
                                Obras   obras   = new Obras();
                                ObrasBO obrasBO = new ObrasBO();


                                obras.Moradores.CodMorador = Convert.ToInt16(lblMoradorCod.Text);
                                obras.BA.Ba_Cod            = Convert.ToInt16(lblBACod.Text);
                                obras.DataHora             = Convert.ToDateTime(mskData.Text);


                                obrasBO.Gravar(obras);
                                MessageBox.Show("Obra cadastrada com sucesso");

                                txtProprietario.Clear();
                                txtApto.Clear();
                                txtBloco.Clear();
                                mskData.Clear();
                            }
                            catch
                            {
                                MessageBox.Show("Verifique os dados e tente novamente");
                            }
                        }
                    }

                    catch
                    {
                        MessageBox.Show("Verifique os dados e tente novamente");
                    }
                }
            }
            catch
            {
                MessageBox.Show("Verifique os dados e tente novamente");
            }
        }
Example #23
0
        private void btnCadastrar_Click(object sender, EventArgs e)
        {
            try
            {
                //puxar codigo do ba
                BA   ba   = new BA();
                BABO babo = new BABO();

                ba.Apto  = txtApto.Text;
                ba.Bloco = txtBloco.Text;

                babo.BuscaCodBA(ba);

                if ((ba.Bloco == "") || (ba.Apto == ""))
                {
                    MessageBox.Show("Bloco/Apartamento não encontrado");
                    txtApto.Clear();
                    txtBloco.Clear();
                }

                else
                {
                    lblBACod.Text = Convert.ToString(ba.Ba_Cod);
                    try
                    {
                        Moradores   mor   = new Moradores();
                        MoradoresBO morBO = new MoradoresBO();


                        mor.Nome = txtProprietario.Text;
                        morBO.Buscar(mor);

                        if (mor.Nome == "")
                        {
                            MessageBox.Show("Proprietário não encontrado");
                            txtProprietario.Clear();
                        }

                        else
                        {
                            lblMoradorCod.Text = Convert.ToString(mor.CodMorador);
                            try
                            {
                                //  add veiculos
                                Veiculos   veiculos   = new Veiculos();
                                VeiculosBO veiculosBO = new VeiculosBO();
                                veiculos.Modelo = txtModelo.Text;
                                veiculos.Placa  = mskPlaca.Text.ToUpper();;

                                if ((veiculos.Modelo == "") || (veiculos.Modelo == null) || (veiculos.Placa == "   -"))
                                {
                                    MessageBox.Show("Preencha todos os campos");
                                }

                                else
                                {
                                    veiculos.Placa = mskPlaca.Text.ToUpper();;
                                    veiculos.Moradores.CodMorador = Convert.ToInt16(lblMoradorCod.Text);
                                    veiculos.BA.Ba_Cod            = Convert.ToInt16(lblBACod.Text);
                                    veiculos.Modelo = txtModelo.Text.ToUpper();
                                    veiculos.Cor    = cbbCor.SelectedItem.ToString();


                                    veiculosBO.Gravar(veiculos);
                                    MessageBox.Show("Veículo cadastrado com sucesso");

                                    txtProprietario.Clear();
                                    txtApto.Clear();
                                    txtBloco.Clear();
                                    txtModelo.Clear();
                                    cbbCor.SelectedIndex = -1;
                                    mskPlaca.Clear();
                                }
                            }
                            catch
                            {
                                MessageBox.Show("Verifique os dados e tente novamente");
                            }
                        }
                    }

                    catch
                    {
                        MessageBox.Show("Verifique os dados e tente novamente");
                    }
                }
            }
            catch
            {
                MessageBox.Show("Verifique os dados e tente novamente");
            }
        }
Example #24
0
 public IEnumerable <BankAccount> GetAllBankAccounts()//Linq 4
 {
     return(from BA in DataSource.GetBankAccounts()
            select BA.Clone());
 }
Example #25
0
        private List<CUDDNode> EncodeTransitionBA(BA.Transition transition, Dictionary<string, Expression> declarationDatabase, string processVariableName)
        {
            //
            Expression transitionDD = Expression.EQ(new Variable(processVariableName),
                                                            new IntConstant(this.stateIndexOfCurrentProcess[transition.FromState]));
            transitionDD = Expression.AND(transitionDD, new Assignment(processVariableName, new IntConstant(this.stateIndexOfCurrentProcess[transition.ToState])));

            List<CUDDNode> transBDD = new List<CUDDNode> { CUDD.Constant(1) };

            foreach (Proposition label in transition.labels)
            {
                List<CUDDNode> temp;

                if (!label.IsSigmal)
                {
                    //label is a propostion
                    if (declarationDatabase != null && declarationDatabase.ContainsKey(label.Label))
                    {
                        Expression proposition = (label.Negated)
                                                     ? Expression.NOT(declarationDatabase[label.Label])
                                                     : declarationDatabase[label.Label];
                        temp = EncodeProposition(transitionDD, proposition);
                    }
                    else
                    {
                        //label is an event
                        //Because we mark event with update with # at the begininig
                        //At this step, we don't know whether the event has update, therefore we check both state
                        Expression eventExpression = Expression.OR(
                                                                              GetEventExpression(label.Label),
                                                                              GetEventExpression(Model.NAME_SEPERATOR +
                                                                                                 label.Label));
                        if(label.Negated)
                        {
                            eventExpression = Expression.NOT(eventExpression);
                        }

                        transitionDD = Expression.AND(transitionDD, eventExpression);
                        temp = transitionDD.TranslateBoolExpToBDD(model).GuardDDs;
                    }
                }
                else
                {
                    temp = transitionDD.TranslateBoolExpToBDD(model).GuardDDs;
                }

                transBDD = CUDD.Function.And(transBDD, temp);
            }

            //
            return transBDD;
        }
Example #26
0
        public override void Confirm()
        {
            bool checkSuccessful = true;
            int  n = SelectedTransforms.Length;

            while (--n > -1)
            {               // Prevents situations, when a GameObject was deleted, while being operated on
                if (SelectedTransforms[n] == null || SelectedTransforms[n].gameObject == null)
                {
                    checkSuccessful = false;
                    TerminateAction = true;
                    break;
                }
            }

            if (!checkSuccessful)
            {
                Cancel();
            }
            else
            {
                base.Confirm();
                BA.ResetTransformLock();
                // Before confirming we reverse the models to their original states to save an undo record.
                //	This is better than saving undo at the start of the trasformation because it prevents undo glitches
                //	and empty undos.
                // First - save the current sates.
                Vector3        currentColliderCenter = Vector3.zero;
                List <Vector3> currentLocalPositions = new List <Vector3>();

                if (BA.ColliderBeingEdited != null)                                        //#colreg(green);
                {
                    currentColliderCenter = Utils.GetEditableColliderCenterLocalSpace(BA); //#endcolreg
                }
                else
                {
                    for (int i = 0; i < SelectedTransforms.Length; i++)
                    {
                        currentLocalPositions.Add(SelectedTransforms[i].localPosition);
                    }
                }

                // Reset the models
                UpdatePositions(OrigAvgPivot);

                //Save an undo record
                Undo.IncrementCurrentGroup();
                if (BA.ColliderBeingEdited != null)                         //#colreg(green);
                {
                    Undo.RecordObject(BA.ColliderBeingEdited, "Translate"); //#endcolreg
                }
                else
                {
                    for (int i = 0; i < SelectedTransforms.Length; i++)
                    {
                        Undo.RecordObject(SelectedTransforms[i], "Translate");
                    }
                }

                // Restore the saved models states
                if (BA.ColliderBeingEdited != null)                                       //#colreg(green);
                {
                    Utils.SetEditableColliderCenterLocalSpace(currentColliderCenter, BA); //#endcolreg
                }
                else
                {
                    for (int i = 0; i < SelectedTransforms.Length; i++)
                    {
                        SelectedTransforms[i].localPosition = currentLocalPositions[i];
                    }
                }
            }
        }
Example #27
0
        private void btnAlterar_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < dataGridView1.RowCount; i++)
            {
                dataGridView1.Rows[i].DataGridView.Columns.Clear();
            }


            try
            {
                //pega codigo bloco apartamento
                BA   ba   = new BA();
                BABO babo = new BABO();

                ba.Apto  = txtApto.Text;
                ba.Bloco = txtBloco.Text;

                babo.BuscaCodBA(ba);

                if ((ba.Bloco == "") || (ba.Apto == ""))
                {
                    MessageBox.Show("Bloco/Apartamento não encontrado");
                    txtApto.Clear();
                    txtBloco.Clear();
                }

                else
                {
                    lblBACod.Text = Convert.ToString(ba.Ba_Cod);


                    try
                    {   //pega codigo morador
                        Moradores   mor   = new Moradores();
                        MoradoresBO morBO = new MoradoresBO();


                        mor.Nome = txtProprietario.Text;
                        morBO.Buscar(mor);

                        if (mor.Nome == "")
                        {
                            MessageBox.Show("Proprietário não encontrado");
                            txtProprietario.Clear();
                        }

                        else
                        {
                            lblMoradorCod.Text = Convert.ToString(mor.CodMorador);
                            //altera o pet
                            try
                            {
                                Locacoes   loc   = new Locacoes();
                                LocacoesBO locBO = new LocacoesBO();

                                loc.CodLocacao           = Convert.ToInt16(lblCodLocacao.Text);
                                loc.Inicio               = Convert.ToDateTime(mskHorarioInicio.Text);
                                loc.Moradores.CodMorador = Convert.ToInt16(lblMoradorCod.Text);
                                loc.BA.Ba_Cod            = Convert.ToInt16(lblBACod.Text);
                                loc.Termino              = Convert.ToDateTime(mskHorarioTermino.Text);

                                locBO.Editar(loc);
                                MessageBox.Show("Locação editada com sucesso");

                                txtProprietario.Clear();
                                txtApto.Clear();
                                txtBloco.Clear();;
                                mskHorarioTermino.Clear();
                                mskHorarioInicio.Clear();
                                txtBusca.Clear();
                                panel1.Enabled     = false;
                                btnAlterar.Enabled = false;
                            }
                            catch
                            {
                                MessageBox.Show("Verifique os dados e tente novamente");
                            }
                        }
                    }

                    catch
                    {
                        MessageBox.Show("Verifique os dados e tente novamente");
                    }
                }
            }
            catch
            {
                MessageBox.Show("Verifique os dados e tente novamente");
            }
        }
Example #28
0
File: Program.cs Project: AyrA/R5
        private static int Join(string DirName, string FileName)
        {
            string SourceFile = null;

            //Check if directory name is a single file and adjust values as needed
            if (File.Exists(DirName))
            {
                SourceFile = Path.GetFileName(DirName);
                DirName    = Path.GetDirectoryName(DirName);
            }
            if (Directory.Exists(DirName))
            {
                var FileList = new Dictionary <string, Header>();
                if (SourceFile == null)
                {
                    Error.WriteLine("Header Collect: Auto detecting files with headers");
                    foreach (var F in Directory.EnumerateFiles(DirName))
                    {
                        var H = GetHeader(F);
                        if (H != null)
                        {
                            Error.WriteLine("Header Collect: Detected header in {0}", Path.GetFileName(F));
                            FileList.Add(F, H);
                        }
                    }
                    if (FileList.Count == 0)
                    {
                        Error.WriteLine("Header Collect: No files found with a valid header");
                        return(RET.NOT_FOUND);
                    }
                    if (!FileList.All(m => m.Value.Id == FileList.First().Value.Id))
                    {
                        Error.WriteLine("Header Collect: Multiple different headers found in the given directory. Please specify one file as input");
                        return(RET.AMBIGUOUS);
                    }
                }
                else
                {
                    var TestHeader = GetHeader(Path.Combine(DirName, SourceFile));
                    if (TestHeader == null)
                    {
                        Error.WriteLine("Header Collect: The file contains no valid header");
                        return(RET.NO_HEADER);
                    }
                    //Get all matching headers
                    foreach (var F in Directory.EnumerateFiles(DirName))
                    {
                        var H = GetHeader(F);
                        if (H != null)
                        {
                            if (H != null && H.Id == TestHeader.Id)
                            {
                                Error.WriteLine("Header Collect: Adding Header ", TestHeader.PartNumber);
                                FileList.Add(F, H);
                            }
                            else
                            {
                                Error.WriteLine("Header Collect: Ignoring header {0}", TestHeader.Id);
                            }
                        }
                    }
                }
                //TODO: Remove duplicate headers in case the user accidentally copied some header twice
                if (!ValidateHeaders(FileList.Select(m => m.Value).ToArray()))
                {
                    Error.WriteLine("Header Check: Detected duplicate/corrupt headers");
                    return(RET.INVALID_HEADER);
                }

                var HeaderList = FileList.Select(m => m.Value).OrderBy(m => m.PartNumber).ToArray();

                //Recover damaged part if needed
                if (!HasAllParts(HeaderList))
                {
                    Error.WriteLine("Join: File list has missing part");
                    if (!CanRecover(HeaderList))
                    {
                        Error.WriteLine("Join: Unable to recover. Can only recover one part, need CRC for recovery");
                        Error.WriteLine("Join: Make sure you either have all parts, or the CRC file with at most one missing part.");
                        return(RET.CANT_RECOVER);
                    }
                    using (var FS = File.Create(FileName))
                    {
                        long     PosMissing = 0;
                        var      Missing    = GetMissingId(HeaderList);
                        var      CRC        = FileList.First(m => m.Value.PartNumber == 0);
                        BitArray BA         = new BitArray(GetFileContent(CRC.Key));
                        Error.WriteLine("Join: Missing part is {0}", Missing);
                        for (var i = 1; i <= CRC.Value.PartCount; i++)
                        {
                            var Current = FileList.FirstOrDefault(m => m.Value.PartNumber == i);

                            if (i == Missing)
                            {
                                Error.WriteLine("Join Part {0}: Writing dummy segment", i);
                                //Write placeholder
                                PosMissing = FS.Position;
                                FS.Write(new byte[BA.Length / 8], 0, BA.Length / 8);
                            }
                            else
                            {
                                Error.WriteLine("Join Part {0}: Writing file segment", i);
                                var Content = GetFileContent(Current.Key);
                                FS.Write(Content, 0, Content.Length);
                                //BitArray needs equal length arrays
                                //The missing bytes are set to zero, which is the same as when we split the file
                                if (Content.Length < BA.Length / 8)
                                {
                                    Array.Resize(ref Content, BA.Length / 8);
                                }
                                BA.Xor(new BitArray(Content));
                            }
                        }
                        Error.WriteLine("Join Part {0}: Writing recovered segment", Missing);
                        FS.Flush();
                        FS.Position = PosMissing;
                        byte[] Temp = new byte[BA.Length / 8];
                        BA.CopyTo(Temp, 0);
                        FS.Write(Temp, 0, Temp.Length);

                        //Trim file if needed (might be too large if the last part was the recovered one)
                        if (FS.Position > CRC.Value.FileSize)
                        {
                            FS.Flush();
                            FS.Position = CRC.Value.FileSize;
                            FS.SetLength(CRC.Value.FileSize);
                        }

                        try
                        {
                            Error.WriteLine("Part Generator: Trying to recreate part {0}", Missing);
                            var CH = CRC.Value;
                            CH.PartNumber = Missing;
                            var NewName = Path.Combine(Path.GetDirectoryName(CRC.Key), CH.FileName) + string.Format(".{0:000}", Missing);
                            if (File.Exists(NewName))
                            {
                                throw new IOException($"{NewName} already exists");
                            }
                            using (var REC = File.Create(NewName))
                            {
                                CH.Serialize(REC);
                                REC.Write(Temp, 0, Temp.Length);
                            }
                            Error.WriteLine("Part Generator: Recreated part {0}", Missing);
                        }
                        catch (Exception ex)
                        {
                            Error.WriteLine("Part Generator: Unable to recreate part {0}", Missing);
                            Error.WriteLine("Part Generator: {0}", ex.Message);
                        }
                    }
                }
                else
                {
                    var HasCRC = FileList.Any(m => m.Value.PartNumber == 0);
                    Error.WriteLine("Join: File has all parts. Recovering normally");
                    if (!HasCRC)
                    {
                        Error.WriteLine("Join: CRC missing, will generate again");
                    }
                    //All parts here
                    var First = FileList.First(m => m.Value.PartNumber == 1).Value;
                    using (var FS = File.Create(FileName))
                    {
                        BitArray BA = null;
                        for (var i = 1; i <= First.PartCount; i++)
                        {
                            Error.WriteLine("Join Part {0}: Writing file segment", i);
                            byte[] Data = GetFileContent(FileList.First(m => m.Value.PartNumber == i).Key);
                            FS.Write(Data, 0, Data.Length);
                            if (!HasCRC)
                            {
                                if (BA == null)
                                {
                                    BA = new BitArray(Data);
                                }
                                else
                                {
                                    if (Data.Length < BA.Length / 8)
                                    {
                                        Array.Resize(ref Data, BA.Length / 8);
                                    }
                                    BA.Xor(new BitArray(Data));
                                }
                            }
                        }
                        //Trim file if needed
                        if (FS.Position > First.FileSize)
                        {
                            FS.Flush();
                            FS.Position = First.FileSize;
                            FS.SetLength(First.FileSize);
                        }
                        //Recover CRC if needed
                        if (BA != null)
                        {
                            var H = HeaderList.First();
                            //Generate part name from existing Header
                            var NewName = Path.Combine(Path.GetDirectoryName(FileName), H.FileName) + ".crc";
                            H.PartNumber = 0;
                            try
                            {
                                Error.WriteLine("Part Generator: Trying to recreate CRC");
                                if (File.Exists(NewName))
                                {
                                    throw new IOException($"{NewName} already exists");
                                }
                                using (var CRC = File.Create(NewName))
                                {
                                    H.Serialize(CRC);
                                    byte[] Data = new byte[BA.Length / 8];
                                    BA.CopyTo(Data, 0);
                                    CRC.Write(Data, 0, Data.Length);
                                }
                                Error.WriteLine("Part Generator: Recreated CRC");
                            }
                            catch (Exception ex)
                            {
                                Error.WriteLine("Part Generator: Unable to recreate CRC");
                                Error.WriteLine("Part Generator: {0}", ex.Message);
                            }
                        }
                    }
                }
            }
            else
            {
                Error.WriteLine("Header Collect: Directory not found: {0}", DirName);
                return(RET.NOT_FOUND);
            }
            return(RET.SUCCESS);
        }
Example #29
0
        public async Task <ActionResult> EditaAdmin(AdminListDetailsBeacon model)
        {
            DataService dataService = new DataService();

            if (ModelState.IsValid)
            {
                Admin novoAdmin = new Admin();
                if (User.Identity.Name == "toze")
                {
                    novoAdmin.name     = model.EditaAdminViewModel.Nome;
                    novoAdmin.username = model.EditaAdminViewModel.Username;
                    novoAdmin.email    = model.EditaAdminViewModel.Email;
                    novoAdmin.password = model.EditaAdminViewModel.Password;
                }
                else
                {
                    string pass = sha256_hash(model.EditaAdminViewModel.Password);
                    novoAdmin.name     = model.EditaAdminViewModel.Nome;
                    novoAdmin.username = model.EditaAdminViewModel.Username;
                    novoAdmin.email    = model.EditaAdminViewModel.Email;
                    novoAdmin.password = pass;
                }

                if (User.Identity.Name == "toze")
                {
                    List <BA> baaa = new List <BA>();
                    baaa = dataService.GetBAAsync();
                    int max = 0;
                    int i   = 0;
                    for (i = 0; i < baaa.Count(); i++)
                    {
                        if (max < baaa[i].baID)
                        {
                            max = baaa[i].baID;
                        }
                    }
                    for (i = 0; i < model.listaDetailsBeacon.Count(); i++)
                    {
                        if (model.listaDetailsBeacon[i].addAdmin == true && baaa.FirstOrDefault(x => x.beaconID == model.listaDetailsBeacon[i].beaconID && x.adminemail == model.EditaAdminViewModel.Email) == null)
                        {
                            max = max + 1;
                            BA ba = new BA();
                            ba.baID       = max;
                            ba.adminemail = model.EditaAdminViewModel.Email;
                            ba.beaconID   = model.listaDetailsBeacon[i].beaconID;
                            bool verdade = dataService.AddBaAsync(ba);
                        }
                        else if (baaa.FirstOrDefault(x => model.listaDetailsBeacon[i].addAdmin == true && x.beaconID == model.listaDetailsBeacon[i].beaconID && x.adminemail == model.EditaAdminViewModel.Email) != null)
                        {
                            continue;
                        }
                        else
                        {
                            for (int j = 0; j < baaa.Count(); j++)
                            {
                                if (baaa[j].adminemail == model.EditaAdminViewModel.Email && baaa[j].beaconID == model.listaDetailsBeacon[i].beaconID)
                                {
                                    dataService.DeletaBAAsync(baaa[j].baID);
                                    break;
                                }
                            }
                        }
                    }
                }

                bool a = await dataService.UpdateAdmin(novoAdmin);

                if (a == true)
                {
                    Success(string.Format("'<b>{0}</b>' edited with success!", model.EditaAdminViewModel.Nome), true);
                    return(RedirectToAction("Index", "Home"));
                }
                ModelState.AddModelError("", "User already registered");
            }


            return(View(model));
        }
Example #30
0
        public async Task <ActionResult> CriaBeaconAsync(CityList model)
        {
            string      men         = model.CreateBeacon.Mesage;
            string      username    = User.Identity.GetUserName();
            DataService dataService = new DataService();
            Admin       ad          = new Admin();

            ad = await dataService.GetAdminByIdAsync(username);

            string admin = "";
            int    flag  = 0;

            if (ad == null)
            {
                SuperAdmin superadmin = new SuperAdmin();
                superadmin = await dataService.GetSuperAdminByIdAsync(username);

                admin = superadmin.email;
                flag  = 1;
            }
            else
            {
                admin = ad.email;
                flag  = 0;
            }

            Beacon beacon = new Beacon();

            beacon.beaconID   = model.CreateBeacon.BeaconId;
            beacon.majorvalue = model.CreateBeacon.MajorValue;
            beacon.minorvalue = model.CreateBeacon.MinorValue;
            beacon.model      = model.CreateBeacon.Model;
            if (model.CreateBeacon.Nome.Contains("-") || model.CreateBeacon.Mesage.Contains("-"))
            {
                ModelState.AddModelError("", "Beacon should not contain - in the name and in the message.");
                return(View(model));
            }
            if (model.CreateBeacon.ActiveBeacon == true)
            {
                beacon.name = "active-" + model.CreateBeacon.Nome + "-0";
            }
            else
            {
                beacon.name = "inactive-" + model.CreateBeacon.Nome + "-0";
            }
            List <ListaAdminB> lista = new List <ListaAdminB>();
            List <BA>          baaa  = new List <BA>();

            baaa = dataService.GetBAAsync();
            int max = 0;
            int i   = 0;

            for (i = 0; i < baaa.Count(); i++)
            {
                if (max < baaa[i].baID)
                {
                    max = baaa[i].baID;
                }
            }
            //lista = (List<ListaAdminB>)model2;
            bool a = await dataService.AddBeaconAsync(beacon, admin, men, flag);

            for (i = 0; i < model.list.Count(); i++)
            {
                if (model.list[i].addAdmin == true)
                {
                    max = max + 1;
                    BA ba = new BA();
                    ba.baID       = max;
                    ba.adminemail = model.list[i].Email;
                    ba.beaconID   = model.CreateBeacon.BeaconId;
                    bool verdade = dataService.AddBaAsync(ba);
                }
            }


            if (a == true)
            {
                Success(string.Format("<b>{0}</b> created with success!", beacon.beaconID), true);
                return(RedirectToAction("Index", "Home"));
            }

            ModelState.AddModelError("", "Beacon already registered.");


            return(View(model));
        }
Example #31
0
        public async Task <ActionResult> EditBeacon(CityListEdit model)
        {
            Uri         aaaa        = Request.UrlReferrer;
            DataService dataService = new DataService();

            if (!ModelState.IsValid)
            {
                return(Redirect(aaaa.ToString()));
            }


            string         uri   = aaaa.ToString();
            string         param = string.Join(string.Empty, uri.Split('/').Skip(5));
            List <Content> con   = new List <Content>();

            con = await dataService.GetContentAsync();

            Content cont = new Content();

            Beacon alterabeacon = new Beacon();

            cont = con.FirstOrDefault(x => x.beaconID == model.EditBeaconViewModel.BeaconID);
            alterabeacon.beaconID   = param;
            alterabeacon.majorvalue = model.EditBeaconViewModel.MajorValue;
            alterabeacon.minorvalue = model.EditBeaconViewModel.MinorValue;
            alterabeacon.model      = model.EditBeaconViewModel.Name;

            if (model.EditBeaconViewModel.ActiveBeacon == true)
            {
                alterabeacon.name = "active-" + model.EditBeaconViewModel.Nome + "-" + model.EditBeaconViewModel.Hide;
            }
            else
            {
                alterabeacon.name = "inactive-" + model.EditBeaconViewModel.Nome + "-" + model.EditBeaconViewModel.Hide;
            }
            cont.contentmsg = model.EditBeaconViewModel.Mensagem;
            string username = User.Identity.GetUserName();
            Admin  admin    = new Admin();

            admin = await dataService.GetAdminByIdAsync(username);

            bool a = false;

            if (admin == null)
            {
                SuperAdmin superadmin = new SuperAdmin();
                superadmin = await dataService.GetSuperAdminByIdAsync(username);

                a = await dataService.UpdateBeacoon(alterabeacon, superadmin.email);
            }
            else
            {
                a = await dataService.UpdateBeacoon(alterabeacon, admin.email);
            }

            bool b = await dataService.UpdateContent(cont);


            List <BA> baaa = new List <BA>();

            baaa = dataService.GetBAAsync();
            int max = 0;
            int i   = 0;

            for (i = 0; i < baaa.Count(); i++)
            {
                if (max < baaa[i].baID)
                {
                    max = baaa[i].baID;
                }
            }
            for (i = 0; i < model.listaa.Count(); i++)
            {
                if (model.listaa[i].addAdmin == true && baaa.FirstOrDefault(x => x.beaconID == model.EditBeaconViewModel.BeaconID && x.adminemail == model.listaa[i].Email) == null)
                {
                    max = max + 1;
                    BA ba = new BA();
                    ba.baID       = max;
                    ba.adminemail = model.listaa[i].Email;
                    ba.beaconID   = model.EditBeaconViewModel.BeaconID;
                    bool verdade = dataService.AddBaAsync(ba);
                }
                else if (baaa.FirstOrDefault(x => model.listaa[i].addAdmin == true && x.beaconID == model.EditBeaconViewModel.BeaconID && x.adminemail == model.listaa[i].Email) != null)
                {
                    continue;
                }
                else
                {
                    for (int j = 0; j < baaa.Count(); j++)
                    {
                        if (baaa[j].adminemail == model.listaa[i].Email && baaa[j].beaconID == model.EditBeaconViewModel.BeaconID)
                        {
                            dataService.DeletaBAAsync(baaa[j].baID);
                            break;
                        }
                    }
                }
            }


            if (a == true && b == true)
            {
                Success(string.Format("<b>{0}</b> was successfully edited", alterabeacon.beaconID), true);
                return(RedirectToAction("Index", "Home"));
            }
            ModelState.AddModelError("", "A problem occurred while saving beacon. Please try again later.");

            Danger(string.Format("<b>{0}</b> could not be edited", alterabeacon.beaconID), true);
            return(View(aaaa));
        }