예제 #1
0
 public bool AddAbsence(vwAbsence absence)
 {
     try
     {
         using (DAN_LIIIEntities context = new DAN_LIIIEntities())
         {
             tblAbsence newAbsence = new tblAbsence
             {
                 FirstDay      = absence.FirstDay,
                 LastDay       = absence.LastDay,
                 StatusRequest = "on hold",
                 Reason        = absence.Reason,
                 UserID        = absence.UserID
             };
             context.tblAbsences.Add(newAbsence);
             context.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine("Exception" + ex.Message.ToString());
         return(false);
     }
 }
예제 #2
0
 public List <vwAbsence> GetRequests(vwEmployee employee)
 {
     try
     {
         using (DAN_LIIIEntities context = new DAN_LIIIEntities())
         {
             return(context.vwAbsences.Where(x => x.UserID == employee.UserID).ToList());
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine("Exception" + ex.Message.ToString());
         return(null);
     }
 }
예제 #3
0
 public vwEmployee FindEmployee(string username)
 {
     try
     {
         using (DAN_LIIIEntities context = new DAN_LIIIEntities())
         {
             vwEmployee employee = (from e in context.vwEmployees where e.Username == username select e).First();
             return(employee);
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine("Exception" + ex.Message.ToString());
         return(null);
     }
 }
예제 #4
0
 /// <summary>
 /// Find the manager by username
 /// </summary>
 /// <param name="username"></param>
 /// <returns></returns>
 public vwManager FindManager(string username)
 {
     try
     {
         using (DAN_LIIIEntities context = new DAN_LIIIEntities())
         {
             vwManager manager = (from e in context.vwManagers where e.Username == username select e).First();
             return(manager);
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine("Exception" + ex.Message.ToString());
         return(null);
     }
 }
예제 #5
0
 public List <vwManager> GetAllManagerView()
 {
     try
     {
         using (DAN_LIIIEntities context = new DAN_LIIIEntities())
         {
             List <vwManager> list = new List <vwManager>();
             list = (from x in context.vwManagers select x).ToList();
             return(list);
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine("Exception" + ex.Message.ToString());
         return(null);
     }
 }
예제 #6
0
 public bool RejectRequest(vwAbsence request)
 {
     try
     {
         using (DAN_LIIIEntities context = new DAN_LIIIEntities())
         {
             tblAbsence requestToReject = context.tblAbsences.Where(x => x.AbsenceID == request.AbsenceID).FirstOrDefault();
             requestToReject.StatusRequest = "rejected";
             context.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine("Exception" + ex.Message.ToString());
         return(false);
     }
 }
예제 #7
0
 public bool CanCreateEmployee(vwEmployee employee)
 {
     try
     {
         using (DAN_LIIIEntities context = new DAN_LIIIEntities())
         {
             var managers = context.vwManagers.Where(x => x.HotelFloor == employee.HotelFloor).FirstOrDefault();
             if (managers != null)
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine("Exception" + ex.Message.ToString());
         return(false);
     }
 }
예제 #8
0
 public bool AddEmployee(vwEmployee addemployee)
 {
     try
     {
         using (DAN_LIIIEntities context = new DAN_LIIIEntities())
         {
             tblUser user = new tblUser
             {
                 DateOfBirth = addemployee.DateOfBirth,
                 Email       = addemployee.Email,
                 NameSurname = addemployee.NameSurname,
                 Pasword     = addemployee.Pasword,
                 Username    = addemployee.Username
             };
             context.tblUsers.Add(user);
             context.SaveChanges();
             addemployee.UserID = user.UserID;
             tblEmployee employee = new tblEmployee
             {
                 UserID      = user.UserID,
                 Citizenship = addemployee.Citizenship,
                 Engagment   = addemployee.Engagment,
                 Gender      = addemployee.Gender,
                 HotelFloor  = addemployee.HotelFloor,
             };
             context.tblEmployees.Add(employee);
             context.SaveChanges();
             addemployee.EmployeeID = employee.EmployeeID;
             return(true);
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine("Exception" + ex.Message.ToString());
         return(false);
     }
 }
예제 #9
0
        public bool IsUser(string username)
        {
            try
            {
                using (DAN_LIIIEntities context = new DAN_LIIIEntities())
                {
                    vwManager manager = (from e in context.vwManagers where e.Username == username select e).First();

                    if (manager == null)
                    {
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Exception" + ex.Message.ToString());
                return(false);
            }
        }
예제 #10
0
 public bool AddManager(vwManager addmanager)
 {
     try
     {
         using (DAN_LIIIEntities context = new DAN_LIIIEntities())
         {
             tblUser user = new tblUser
             {
                 DateOfBirth = addmanager.DateOfBirth,
                 Email       = addmanager.Email,
                 NameSurname = addmanager.NameSurname,
                 Pasword     = addmanager.Pasword,
                 Username    = addmanager.Username
             };
             context.tblUsers.Add(user);
             context.SaveChanges();
             addmanager.UserID = user.UserID;
             tblManager manager = new tblManager
             {
                 UserID         = addmanager.UserID,
                 Exprience      = addmanager.Exprience,
                 HotelFloor     = addmanager.HotelFloor,
                 Qualifications = addmanager.Qualifications
             };
             context.tblManagers.Add(manager);
             context.SaveChanges();
             addmanager.ManagerID = manager.ManagerID;
             return(true);
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine("Exception" + ex.Message.ToString());
         return(false);
     }
 }