Beispiel #1
0
 public bool InsertOrUpdateDepartment(tbl_Taxi_Department_Infor department)
 {
     try
     {
         var departmentFind = db.tbl_Taxi_Department_Infor.FirstOrDefault(x => x.DepartmentName == department.DepartmentName);
         if (departmentFind == null)
         {
             db.tbl_Taxi_Department_Infor.Add(department);
         }
         else
         {
             departmentFind.Head_id    = department.Head_id;
             departmentFind.UpdateDate = department.UpdateDate;
         }
         db.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Beispiel #2
0
        public void UpdateUserInformation(EmployeeModel employeeInfor)
        {
            //Get employeeInfor
            //var employeeInfor = (EmployeeModel)Session[CommonConstants.USER_SESSION];
            var headInfor = adWebHelper.GetHeadOfFunction(mEmployee.employee.access_token, employeeInfor.department);

            // User: Insert or update permisstion
            var employeeId = InsertOrUpdateUser(employeeInfor);

            GrantPermisstion(employeeId, 2); // Default permisstion

            // Department: Insert or update with headId
            var headId = InsertOrUpdateUser(headInfor);

            GrantPermisstion(headId, 3); // Default permisstion
            tbl_Taxi_Department_Infor department = new tbl_Taxi_Department_Infor();

            department.DepartmentName = employeeInfor.department;
            department.Head_id        = headId;
            department.UpdateDate     = DateTime.Now;
            new DepartmentDao().InsertOrUpdateDepartment(department);
        }