Пример #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 bool ApproveRequest(vwAbsence request)
 {
     try
     {
         using (DAN_LIIIEntities context = new DAN_LIIIEntities())
         {
             tblAbsence requestToApprove = context.tblAbsences.Where(x => x.AbsenceID == request.AbsenceID).FirstOrDefault();
             requestToApprove.StatusRequest = "approved";
             context.SaveChanges();
             context.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine("Exception" + ex.Message.ToString());
         return(false);
     }
 }
Пример #3
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);
     }
 }
Пример #4
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);
     }
 }