public int changeMedicData(string username, string password, string cnp, string email, string lastname, string firstname, string address, string dateofbirth, string specializare)
        {
            datamedic   medic  = new datamedic();
            MedicDetail detail = new MedicDetail();

            using (MedicDBEntities3 db = new MedicDBEntities3())
            {
                try
                {
                    medic = db.datamedics.Where(x => x.cnp == cnp).FirstOrDefault();

                    medic.password = password;
                    //changing cnp is prohibited, because this is key information (for identifying)
                    medic.email    = email;
                    medic.username = username;

                    db.Entry(medic).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();

                    detail                 = db.MedicDetails.Where(x => x.cnp == medic.cnp).FirstOrDefault();
                    detail.lastname        = lastname;
                    detail.firstname       = firstname;
                    detail.address         = address;
                    detail.dateofbirth     = dateofbirth;
                    detail.specializare    = specializare;
                    db.Entry(detail).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                }
                catch
                {
                    return(-1);
                }
                return(1);
            } //using
        }     //changeMedicData()
        public int deletePacient(string pUser, string pCNP)
        {
            Pacienti      pacient = new Pacienti();
            PacientDetail detail  = new PacientDetail();

            using (MedicDBEntities3 md = new MedicDBEntities3())
            {
                try
                {
                    pacient = md.Pacientis.Where(x => x.username == pUser).FirstOrDefault();

                    if (pacient.pacient_cnp != pCNP)
                    {
                        return(-1);
                    }
                    detail = md.PacientDetails.Where(x => x.pacient_cnp == pacient.pacient_cnp).FirstOrDefault();
                    var entry = md.Entry(detail);
                    if (entry.State == System.Data.Entity.EntityState.Detached)
                    {
                        md.PacientDetails.Attach(detail);
                    }
                    md.PacientDetails.Remove(detail);
                    md.SaveChanges();

                    var entry1 = md.Entry(pacient);
                    if (entry1.State == System.Data.Entity.EntityState.Detached)
                    {
                        md.Pacientis.Attach(pacient);
                    }
                    md.Pacientis.Remove(pacient);
                    md.SaveChanges();
                }
                catch
                {
                    return(-2);
                }
                return(1);
            }
        }
        public int deleteMedicAccount(string username, string cnp)
        {
            datamedic   medic  = new datamedic();
            MedicDetail detail = new MedicDetail();

            try
            {
                using (MedicDBEntities3 db = new MedicDBEntities3())
                {
                    medic = db.datamedics.Where(x => x.username == username).FirstOrDefault();
                    if (medic.cnp != cnp)
                    {
                        return(-1);
                    }

                    detail = db.MedicDetails.Where(x => x.cnp == medic.cnp).FirstOrDefault();
                    var entry = db.Entry(detail);
                    if (entry.State == System.Data.Entity.EntityState.Detached)
                    {
                        db.MedicDetails.Attach(detail);
                    }
                    db.MedicDetails.Remove(detail);
                    db.SaveChanges();

                    var entry1 = db.Entry(medic);
                    if (entry1.State == System.Data.Entity.EntityState.Detached)
                    {
                        db.datamedics.Attach(medic);
                    }
                    db.datamedics.Remove(medic);
                    db.SaveChanges();
                } //using
            }     //try
            catch
            {
                return(-2);
            } //catch
            return(1);
        }     //function
        public int updatePacientData(string pUser, string pPass, string pCNP, string pEmail, string pLName, string pFName, string pBirth, string pAddress)
        {
            Pacienti      pacient = new Pacienti();
            PacientDetail detail  = new PacientDetail();

            using (MedicDBEntities3 md = new MedicDBEntities3())
            {
                try
                {
                    pacient = md.Pacientis.Where(x => x.pacient_cnp == pCNP).FirstOrDefault();

                    pacient.username = pUser;
                    pacient.password = pPass;
                    pacient.email    = pEmail;

                    //nu vom schimba cnp-ul pentru ca este o informatia esentiala pt cautare

                    md.Entry(pacient).State = System.Data.Entity.EntityState.Modified;
                    md.SaveChanges();

                    detail             = md.PacientDetails.Where(x => x.pacient_cnp == pacient.pacient_cnp).FirstOrDefault();
                    detail.lastname    = pLName;
                    detail.firstname   = pFName;
                    detail.address     = pAddress;
                    detail.dateofbirth = pBirth;

                    md.Entry(detail).State = System.Data.Entity.EntityState.Modified;
                    md.SaveChanges();
                }
                catch
                {
                    return(-1);
                }
                return(1);
            }
        }