/// <summary> /// Insert User into the context (SCAPEDB in this case) /// </summary> /// <param name="user">User to insert</param> public async Task <bool> insertUser(User user) { _context.User.Add(user); await _context.SaveChangesAsync(); return(true); }
/// <summary> /// Insert Attendance into the context (SCAPEDB in this case) /// </summary> /// <param name="attendance">Attendance to insert</param> public async Task <bool> insertAttendance(Attendance attendance) { _context.Attendance.Add(attendance); await _context.SaveChangesAsync(); return(true); }
/// <summary> /// Insert employee into the context (SCAPEDB in this case) /// </summary> /// <param name="employee">Employee to insert</param> public async Task <bool> insertEmployee(Employee employee) { try { _context.Employee.Add(employee); await _context.SaveChangesAsync(); } catch (Exception ex) { if (ex.GetBaseException().GetType() == typeof(SqlException)) { Int32 errorCode = ((SqlException)ex.InnerException).Number; if (errorCode == 2627 || errorCode == 2601) { return(false); } } } return(true); }