Esempio n. 1
0
        public bool InsertAdmin(ref AdminBDO adminBDO,
            ref string massage)
        {
            massage = "Admin inserted successfully";
            var ret = true;
            Password passObj = new Password();
            string[] passAndSalt = passObj.getFullyHash(adminBDO.pass);
            using (var PHEntities = new PublicHospitalEntities())
            {
                PHEntities.Admin.Add(new Admin
                {
                    id = GetNextID(),
                    firstName = adminBDO.firstName,
                    lastName = adminBDO.lastName,
                    city = adminBDO.city,
                    street = adminBDO.street,
                    streetNr = adminBDO.streetNr,
                    phoneNr = adminBDO.phoneNr,
                    zip = adminBDO.zip,
                    login = adminBDO.login,

                    pass = passAndSalt[0],
                    salt = passAndSalt[1]
                });
                var num = PHEntities.SaveChanges();
                if (num != 1)
                {
                    ret = false;
                    massage = "Admin was not inserted";
                }
            }
            return ret;
        }
Esempio n. 2
0
 public bool SaveAdmin(ref Admin admin,
     ref string message)
 {
     var result = true;
     if (!AdminCheck(ref admin, ref message))
     {
         result = false;
     }
     else
     {
         try
         {
             var adminBDO = new AdminBDO();
             TranslateAdminDTOToAdminBDO(admin,
                 adminBDO);
             result = adminLogic.InsertAdmin(
                 ref adminBDO, ref message);
         }
         catch (Exception e)
         {
             var msg = e.Message;
             throw new FaultException<AdminFault>
                 (new AdminFault(msg), msg);
         }
     }
     return result;
 }
Esempio n. 3
0
 public AdminBDO GetAdmin(int id)
 {
     AdminBDO adminBDO = null;
     using (var PHEntities = new PublicHospitalEntities())
     {
         var adminObj = (from a in PHEntities.Admin
                      where a.id == id
                      select a).FirstOrDefault();
         if (adminObj != null)
             adminBDO = new AdminBDO()
             {
                 id = adminObj.id,
                 firstName = adminObj.firstName,
                 lastName = adminObj.lastName,
                 city = adminObj.city,
                 street = adminObj.street,
                 streetNr = adminObj.streetNr,
                 phoneNr = adminObj.phoneNr,
                 zip = adminObj.zip,
                 login = adminObj.login,
                 pass = adminObj.pass
             };
     }
         return adminBDO;
 }
Esempio n. 4
0
 public bool compareSessionID(AdminBDO person)
 {
     if (getSessionIdDB(person.id).Equals(person.sessionID))
         return true;
     else
         return false;
 }
Esempio n. 5
0
 public void compareSessionIDTest()
 {
     AdminBDO p = new AdminBDO();
     p.sessionID = "0C4J8DlS7AHFQa8j4U1Ap39gFDDOeNBJ/N1B2eXw";
     p.id = 11;
     Password pass = new Password();
     if (!pass.compareSessionID(p))
         Assert.Fail();
 }
Esempio n. 6
0
 public void TranslateAdminBDOToAdminDTO(
     AdminBDO adminBDO,
     Admin admin)
 {
     admin.id = adminBDO.id;
     admin.firstName = adminBDO.firstName;
     admin.lastName = adminBDO.lastName;
     admin.city = adminBDO.city;
     admin.zip = adminBDO.zip;
     admin.street = adminBDO.street;
     admin.streetNr = adminBDO.streetNr;
     admin.phoneNr = adminBDO.phoneNr;
     admin.login = adminBDO.login;
     admin.pass = adminBDO.pass;
 }
Esempio n. 7
0
        public bool UpdateAdmin(ref AdminBDO adminBDO,
            ref string massage)
        {
            massage = "Admin updated successfully";
            var ret = true;
            using (var PHEntites = new PublicHospitalEntities())
            {
                var adminId = adminBDO.id;
                var adminInDb = (from a
                                 in PHEntites.Admin
                                 where a.id == adminId
                                 select a).FirstOrDefault();
                if (adminInDb == null)
                {
                    throw new Exception("No admin with id " +
                                        adminBDO.id);
                }
                adminInDb.firstName = adminBDO.firstName;
                adminInDb.lastName = adminBDO.lastName;
                adminInDb.city = adminBDO.city;
                adminInDb.zip = adminBDO.zip;
                adminInDb.street = adminBDO.street;
                adminInDb.streetNr = adminBDO.streetNr;
                adminInDb.phoneNr = adminBDO.phoneNr;
                adminInDb.rowVersion = adminBDO.RowVersion;
                //without username and pass
                PHEntites.Admin.Attach(adminInDb);
                PHEntites.Entry(adminInDb).State = System.Data.Entity.EntityState.Modified;
                var num = PHEntites.SaveChanges();

                adminBDO.RowVersion = adminInDb.rowVersion;

                if (num != 1)
                {
                    ret = false;
                    massage = "Admin was not updated";
                }
            }
            return ret;
        }
Esempio n. 8
0
 private void TranslateAdminDTOToAdminBDO(
     Admin admin,
     AdminBDO adminBDO)
 {
     adminBDO.id = admin.id;
     adminBDO.firstName = admin.firstName;
     adminBDO.lastName = admin.lastName;
     adminBDO.city = admin.city;
     adminBDO.zip = admin.zip;
     adminBDO.street = admin.street;
     adminBDO.streetNr = admin.streetNr;
     adminBDO.phoneNr = admin.phoneNr;
     adminBDO.login = admin.login;
     adminBDO.pass = admin.pass;
     adminBDO.RowVersion = admin.RowVersion;
 }